mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wu Bo <wubo40@huawei.com>
To: <hch@lst.de>, <sagi@grimberg.me>, <chaitanya.kulkarni@wdc.com>,
	<kbusch@kernel.org>, <amit.engel@dell.com>,
	<linux-nvme@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Cc: <linfeilong@huawei.com>, <wubo40@huawei.com>
Subject: [PATCH] nvmet: fix memory leak on nvmet_alloc_ctrl()
Date: Tue, 18 May 2021 16:46:38 +0800	[thread overview]
Message-ID: <1621327598-542045-1-git-send-email-wubo40@huawei.com> (raw)

From: Wu Bo <wubo40@huawei.com>

When cntlid_min is greater than cntlid_max,
goto wrong label, should be goto out_free_sqs
label. Otherwise there is a memory leak problem
on the nvmet_alloc_ctrl function().

Fixes: 94a39d61f80f ("nvmet: make ctrl-id configurable")
Fixes: 6d65aeab7bf6e ("nvmet: remove unused ctrl->cqs")
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
 drivers/nvme/target/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 25cc2ee8de3f..1853db38b682 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1372,7 +1372,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
 		goto out_free_changed_ns_list;
 
 	if (subsys->cntlid_min > subsys->cntlid_max)
-		goto out_free_changed_ns_list;
+		goto out_free_sqs;
 
 	ret = ida_simple_get(&cntlid_ida,
 			     subsys->cntlid_min, subsys->cntlid_max,
-- 
2.30.0


             reply	other threads:[~2021-05-18  8:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18  8:46 Wu Bo [this message]
2021-05-18 17:59 ` Sagi Grimberg
2021-05-18 20:27 ` Chaitanya Kulkarni
2021-05-19  4:32   ` Wu Bo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1621327598-542045-1-git-send-email-wubo40@huawei.com \
    --to=wubo40@huawei.com \
    --cc=amit.engel@dell.com \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®