* Re: [PATCH 1/2] nvmet: Fix memory leak in nvmet_alloc_ctrl()
2021-05-19 5:01 ` [PATCH 1/2] nvmet: Fix memory leak in nvmet_alloc_ctrl() Wu Bo
@ 2021-05-19 4:45 ` Chaitanya Kulkarni
0 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2021-05-19 4:45 UTC (permalink / raw)
To: Wu Bo; +Cc: hch, sagi, kbusch, amit.engel, linux-nvme, linux-kernel, linfeilong
Sent from my iPhone
> On May 18, 2021, at 9:35 PM, Wu Bo <wubo40@huawei.com> wrote:
>
> Fixes: 6d65aeab7bf6e ("nvmet: remove unused ctrl->cqs")
You have extra digit for commit hash here which I have fixed in my review. Also version number is missing from the subject line.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] nvme-loop: Fix memory leak in nvme_loop_create_ctrl()
2021-05-19 5:01 ` [PATCH 2/2] nvme-loop: Fix memory leak in nvme_loop_create_ctrl() Wu Bo
@ 2021-05-19 4:48 ` Chaitanya Kulkarni
0 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2021-05-19 4:48 UTC (permalink / raw)
To: Wu Bo; +Cc: hch, sagi, kbusch, amit.engel, linux-nvme, linux-kernel, linfeilong
Sent from my iPhone
> On May 18, 2021, at 9:35 PM, Wu Bo <wubo40@huawei.com> wrote:
>
> 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")
Please make sure comit logs lines filled up 72 char and
Commit hash is 12 digit.
See the commit logs in the tree to get the better idea.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/2] nvmet: Fix memory leak when create ctrl fails
@ 2021-05-19 5:01 Wu Bo
2021-05-19 5:01 ` [PATCH 1/2] nvmet: Fix memory leak in nvmet_alloc_ctrl() Wu Bo
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Wu Bo @ 2021-05-19 5:01 UTC (permalink / raw)
To: hch, sagi, chaitanya.kulkarni, kbusch, amit.engel, linux-nvme,
linux-kernel
Cc: linfeilong, wubo40
Hi,
This series of patches to fix the issuse of memory leak
when creating ctrl fails.
Wu Bo (2):
nvmet: Fix memory leak in nvmet_alloc_ctrl()
nvme-loop: Fix memory leak in nvme_loop_create_ctrl()
drivers/nvme/target/core.c | 2 +-
drivers/nvme/target/loop.c | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] nvmet: Fix memory leak in nvmet_alloc_ctrl()
2021-05-19 5:01 [PATCH 0/2] nvmet: Fix memory leak when create ctrl fails Wu Bo
@ 2021-05-19 5:01 ` Wu Bo
2021-05-19 4:45 ` Chaitanya Kulkarni
2021-05-19 5:01 ` [PATCH 2/2] nvme-loop: Fix memory leak in nvme_loop_create_ctrl() Wu Bo
2021-05-19 6:35 ` [PATCH 0/2] nvmet: Fix memory leak when create ctrl fails Christoph Hellwig
2 siblings, 1 reply; 6+ messages in thread
From: Wu Bo @ 2021-05-19 5:01 UTC (permalink / raw)
To: hch, sagi, chaitanya.kulkarni, kbusch, amit.engel, linux-nvme,
linux-kernel
Cc: linfeilong, wubo40
From: Wu Bo <wubo40@huawei.com>
When creating ctrl in nvmet_alloc_ctrl(), if the cntlid_min is
large than cntlid_max of the subsystem, and jumps to
"out_free_changed_ns_list" label, but the ctrl->sqs lack of be freed.
So to fix this issuse modify jumps to "out_free_sqs" label.
Fixes: 94a39d61f80f ("nvmet: make ctrl-id configurable")
Fixes: 6d65aeab7bf6e ("nvmet: remove unused ctrl->cqs")
Signed-off-by: Wu Bo <wubo40@huawei.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.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 25cc2ee..1853db3 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,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] nvme-loop: Fix memory leak in nvme_loop_create_ctrl()
2021-05-19 5:01 [PATCH 0/2] nvmet: Fix memory leak when create ctrl fails Wu Bo
2021-05-19 5:01 ` [PATCH 1/2] nvmet: Fix memory leak in nvmet_alloc_ctrl() Wu Bo
@ 2021-05-19 5:01 ` Wu Bo
2021-05-19 4:48 ` Chaitanya Kulkarni
2021-05-19 6:35 ` [PATCH 0/2] nvmet: Fix memory leak when create ctrl fails Christoph Hellwig
2 siblings, 1 reply; 6+ messages in thread
From: Wu Bo @ 2021-05-19 5:01 UTC (permalink / raw)
To: hch, sagi, chaitanya.kulkarni, kbusch, amit.engel, linux-nvme,
linux-kernel
Cc: linfeilong, wubo40
Form: Wu Bo <wubo40@huawei.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@huawei.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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] nvmet: Fix memory leak when create ctrl fails
2021-05-19 5:01 [PATCH 0/2] nvmet: Fix memory leak when create ctrl fails Wu Bo
2021-05-19 5:01 ` [PATCH 1/2] nvmet: Fix memory leak in nvmet_alloc_ctrl() Wu Bo
2021-05-19 5:01 ` [PATCH 2/2] nvme-loop: Fix memory leak in nvme_loop_create_ctrl() Wu Bo
@ 2021-05-19 6:35 ` Christoph Hellwig
2 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-05-19 6:35 UTC (permalink / raw)
To: Wu Bo
Cc: hch, sagi, chaitanya.kulkarni, kbusch, amit.engel, linux-nvme,
linux-kernel, linfeilong
Thanks,
applied to nvme-5.13 with slight tweaks to the commit messages and
fixes tags.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-05-19 6:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 5:01 [PATCH 0/2] nvmet: Fix memory leak when create ctrl fails Wu Bo
2021-05-19 5:01 ` [PATCH 1/2] nvmet: Fix memory leak in nvmet_alloc_ctrl() Wu Bo
2021-05-19 4:45 ` Chaitanya Kulkarni
2021-05-19 5:01 ` [PATCH 2/2] nvme-loop: Fix memory leak in nvme_loop_create_ctrl() Wu Bo
2021-05-19 4:48 ` Chaitanya Kulkarni
2021-05-19 6:35 ` [PATCH 0/2] nvmet: Fix memory leak when create ctrl fails Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).