nvmf: ctrlr_create - fix missing free qpair_mask on error

This patch fixes missing free of qpair_mask when a listener error
occurs in ctrlr_create.

Signed-off-by: Jonas Pfefferle <pepperjo@japf.ch>
Change-Id: I09162b86d8ac73bf9fc2006a08dcc0a955f222b3
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7818
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Jonas Pfefferle 2021-04-14 13:17:42 +02:00 committed by Tomasz Zawadzki
parent e8fc521f7d
commit 19faf91293

View File

@ -336,8 +336,7 @@ nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
ctrlr->qpair_mask = spdk_bit_array_create(transport->opts.max_qpairs_per_ctrlr);
if (!ctrlr->qpair_mask) {
SPDK_ERRLOG("Failed to allocate controller qpair mask\n");
free(ctrlr);
return NULL;
goto err_qpair_mask;
}
nvmf_ctrlr_cdata_init(transport, subsystem, &ctrlr->cdata);
@ -431,15 +430,13 @@ nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
if (ctrlr->subsys->subtype == SPDK_NVMF_SUBTYPE_NVME) {
if (spdk_nvmf_qpair_get_listen_trid(req->qpair, &listen_trid) != 0) {
SPDK_ERRLOG("Could not get listener transport ID\n");
free(ctrlr);
return NULL;
goto err_listener;
}
ctrlr->listener = nvmf_subsystem_find_listener(ctrlr->subsys, &listen_trid);
if (!ctrlr->listener) {
SPDK_ERRLOG("Listener was not found\n");
free(ctrlr);
return NULL;
goto err_listener;
}
}
@ -447,6 +444,11 @@ nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
spdk_thread_send_msg(subsystem->thread, _nvmf_subsystem_add_ctrlr, req);
return ctrlr;
err_listener:
spdk_bit_array_free(&ctrlr->qpair_mask);
err_qpair_mask:
free(ctrlr);
return NULL;
}
static void