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
Form: Wu Bo <[email protected]>
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 <[email protected]>
---
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
From: Wu Bo <[email protected]>
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 <[email protected]>
Reviewed-by: Sagi Grimberg <[email protected]>
Reviewed-by: Chaitanya Kulkarni <[email protected]>
---
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
Sent from my iPhone
> On May 18, 2021, at 9:35 PM, Wu Bo <[email protected]> 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.
Thanks,
applied to nvme-5.13 with slight tweaks to the commit messages and
fixes tags.