lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 19 May 2021 13:01:10 +0800
From:   Wu Bo <wubo40@...wei.com>
To:     <hch@....de>, <sagi@...mberg.me>, <chaitanya.kulkarni@....com>,
        <kbusch@...nel.org>, <amit.engel@...l.com>,
        <linux-nvme@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
CC:     <linfeilong@...wei.com>, <wubo40@...wei.com>
Subject: [PATCH 2/2] nvme-loop: Fix memory leak in nvme_loop_create_ctrl()

Form: Wu Bo <wubo40@...wei.com>

When creating loop ctrl in nvme_loop_create_ctrl(), if nvme_init_ctrl()
returns fails, the loop ctrl should be freed before
jumps to the "out" label.

Fixes: 3a85a5de29ea7 ("nvme-loop: add a NVMe loopback host driver")
Signed-off-by: Wu Bo <wubo40@...wei.com>
---
 drivers/nvme/target/loop.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 74b3b15..cb30cb9 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -590,8 +590,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);
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ