]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvme: put ns_head ref if namespace fails allocation
authorSagi Grimberg <sagi@grimberg.me>
Wed, 13 Mar 2019 17:54:57 +0000 (18:54 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 13 Mar 2019 18:05:39 +0000 (12:05 -0600)
In case nvme_alloc_ns fails after we initialize ns_head but before we
add the ns to the controller namespaces list we need to explicitly put
the ns_head reference because when we teardown the controller we
won't find it, causing us to leak a dangling subsystem eventually.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/core.c

index dc1641247b17b38a64dc237ef25bd29302fec9bb..d57a84f45ed018144175f9419236d7fc933b3b96 100644 (file)
@@ -3304,6 +3304,7 @@ static int nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
        mutex_lock(&ctrl->subsys->lock);
        list_del_rcu(&ns->siblings);
        mutex_unlock(&ctrl->subsys->lock);
+       nvme_put_ns_head(ns->head);
  out_free_id:
        kfree(id);
  out_free_queue: