nvme: Close file descriptor if controller fails to initialize

Change-Id: I9fee91ece79b204962a70fc49d9032abe2c55090
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/408218
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2018-04-17 16:00:07 -07:00 committed by Daniel Verkamp
parent 4988e48294
commit 63fb2f772c

View File

@ -790,6 +790,7 @@ struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(const struct spdk_nvme_transpo
pctrlr = spdk_dma_zmalloc(sizeof(struct nvme_pcie_ctrlr), 64, NULL);
if (pctrlr == NULL) {
close(claim_fd);
SPDK_ERRLOG("could not allocate ctrlr\n");
return NULL;
}
@ -804,6 +805,7 @@ struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(const struct spdk_nvme_transpo
rc = nvme_pcie_ctrlr_allocate_bars(pctrlr);
if (rc != 0) {
close(claim_fd);
spdk_dma_free(pctrlr);
return NULL;
}
@ -815,6 +817,7 @@ struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(const struct spdk_nvme_transpo
if (nvme_ctrlr_get_cap(&pctrlr->ctrlr, &cap)) {
SPDK_ERRLOG("get_cap() failed\n");
close(claim_fd);
spdk_dma_free(pctrlr);
return NULL;
}