nvmet: fix error flow in nvmet_alloc_ctrl()
authorIsrael Rukshin <israelr@mellanox.com>
Mon, 13 Nov 2017 12:29:40 +0000 (12:29 +0000)
committerChristoph Hellwig <hch@lst.de>
Mon, 8 Jan 2018 10:01:58 +0000 (11:01 +0100)
Remove the allocated id on error.

Signed-off-by: Israel Rukshin <israelr@mellanox.com>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/core.c

index b54748ad5f4800cdda6ee83372fd16f2eb574fd3..07eb45d32a7a055acaab75305de7bd3965fb418f 100644 (file)
@@ -830,7 +830,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
                /* Don't accept keep-alive timeout for discovery controllers */
                if (kato) {
                        status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
-                       goto out_free_sqs;
+                       goto out_remove_ida;
                }
 
                /*
@@ -860,6 +860,8 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
        *ctrlp = ctrl;
        return 0;
 
+out_remove_ida:
+       ida_simple_remove(&cntlid_ida, ctrl->cntlid);
 out_free_sqs:
        kfree(ctrl->sqs);
 out_free_cqs: