From 8ba212a80e9a29b21998034fdc9b2d2da8e34216 Mon Sep 17 00:00:00 2001 From: Sagi Grimberg Date: Thu, 22 Oct 2020 20:35:16 +0800 Subject: [PATCH] nvme: put ns_head ref if namespace fails allocation mainline inclusion from mainline-v5.1-rc1 commit a63b83700ba89c300f705167d06bf122f3666287 category: bugfix bugzilla: NA CVE: NA Link: https://gitee.com/openeuler/kernel/issues/I1WGZE -------------------------------- 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 Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe Reviewed-by: Chao Leng Reviewed-by: Jike Cheng Signed-off-by: Lijie Reviewed-by: Tao Hou Signed-off-by: Yang Yingliang --- drivers/nvme/host/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index fad51db54fdb..0b762cd18798 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3247,6 +3247,7 @@ static void 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: -- GitLab