public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nvme-core: fix memory leak in dhchap_secret_store
@ 2023-04-27  8:04 Chaitanya Kulkarni
  2023-04-27  8:04 ` [PATCH 2/2] nvme-core: fix memory leak in dhchap_ctrl_secret Chaitanya Kulkarni
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2023-04-27  8:04 UTC (permalink / raw)
  To: hare; +Cc: kbusch, hch, sagi, linux-nvme, Chaitanya Kulkarni

Free dhchap_secret in nvme_ctrl_dhchap_secret_store() before we return
when nvme_auth_generate_key() returns error.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/nvme/host/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 518c759346f0..5a9d97c0c0c1 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3814,8 +3814,10 @@ static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev,
 		int ret;
 
 		ret = nvme_auth_generate_key(dhchap_secret, &key);
-		if (ret)
+		if (ret) {
+			kfree(dhchap_secret);
 			return ret;
+		}
 		kfree(opts->dhchap_secret);
 		opts->dhchap_secret = dhchap_secret;
 		host_key = ctrl->host_key;
-- 
2.40.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-27 12:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-27  8:04 [PATCH 1/2] nvme-core: fix memory leak in dhchap_secret_store Chaitanya Kulkarni
2023-04-27  8:04 ` [PATCH 2/2] nvme-core: fix memory leak in dhchap_ctrl_secret Chaitanya Kulkarni
2023-04-27  8:09 ` [PATCH 1/2] nvme-core: fix memory leak in dhchap_secret_store Sagi Grimberg
2023-04-27  8:32   ` Chaitanya Kulkarni
2023-04-27 12:32 ` Max Gurtovoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox