Patch "nvme-loop: fix memory leak in nvme_loop_create_ctrl()" has been added to the 5.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nvme-loop: fix memory leak in nvme_loop_create_ctrl()

to the 5.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nvme-loop-fix-memory-leak-in-nvme_loop_create_ctrl.patch
and it can be found in the queue-5.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 5457acdd06bd18ffcff131d82749b36a47843781
Author: Wu Bo <wubo40@xxxxxxxxxx>
Date:   Wed May 19 13:01:10 2021 +0800

    nvme-loop: fix memory leak in nvme_loop_create_ctrl()
    
    [ Upstream commit 03504e3b54cc8118cc26c064e60a0b00c2308708 ]
    
    When creating loop ctrl in nvme_loop_create_ctrl(), if nvme_init_ctrl()
    fails, the loop ctrl should be freed before jumping to the "out" label.
    
    Fixes: 3a85a5de29ea ("nvme-loop: add a NVMe loopback host driver")
    Signed-off-by: Wu Bo <wubo40@xxxxxxxxxx>
    Signed-off-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 3e189e753bcf..14913a4588ec 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -588,8 +588,10 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
 
 	ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_loop_ctrl_ops,
 				0 /* no quirks, we're perfect! */);
-	if (ret)
+	if (ret) {
+		kfree(ctrl);
 		goto out;
+	}
 
 	if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING))
 		WARN_ON_ONCE(1);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux