nvmf: fix transport adding to tgt
adding transport to tgt should be the last step also there is an issue before change i.e. if calloc failed then transport remains on the list Signed-off-by: Jacek Kalwas <jacek.kalwas@intel.com> Change-Id: Iaf29cfc7b0f535d40160c6fdf9ef6a7e6bfb127c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10429 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
1960ef167a
commit
a15b6af0a6
@ -724,11 +724,12 @@ _nvmf_tgt_add_transport_done(struct spdk_io_channel_iter *i, int status)
|
||||
{
|
||||
struct spdk_nvmf_tgt_add_transport_ctx *ctx = spdk_io_channel_iter_get_ctx(i);
|
||||
|
||||
if (status) {
|
||||
TAILQ_REMOVE(&ctx->tgt->transports, ctx->transport, link);
|
||||
if (!status) {
|
||||
ctx->transport->tgt = ctx->tgt;
|
||||
TAILQ_INSERT_TAIL(&ctx->tgt->transports, ctx->transport, link);
|
||||
}
|
||||
ctx->cb_fn(ctx->cb_arg, status);
|
||||
|
||||
ctx->cb_fn(ctx->cb_arg, status);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
@ -756,9 +757,6 @@ void spdk_nvmf_tgt_add_transport(struct spdk_nvmf_tgt *tgt,
|
||||
return; /* transport already created */
|
||||
}
|
||||
|
||||
transport->tgt = tgt;
|
||||
TAILQ_INSERT_TAIL(&tgt->transports, transport, link);
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
if (!ctx) {
|
||||
cb_fn(cb_arg, -ENOMEM);
|
||||
|
Loading…
Reference in New Issue
Block a user