nvmet: Fix memory leak when create ctrl fails
Subsystems (2)
cover nvmet: Fix memory leak when create ctrl fails
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(-)
Signature · 1 line
1.8.3.1
PATCH 1/2 nvmet: Fix memory leak in nvmet_alloc_ctrl()
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.
--- drivers/nvme/target/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/core.c +1 -1
@@ -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,
Signature · 1 line
1.8.3.1
Re: [PATCH 1/2] nvmet: Fix memory leak in nvmet_alloc_ctrl()
Sent from my iPhone
Quoted 3 lines · Wu Bo
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.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH 2/2 nvme-loop: Fix memory leak in nvme_loop_create_ctrl()
In reply to Wu BoForm: 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.
--- drivers/nvme/target/loop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/loop.c +3 -1
@@ -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 );
Signature · 1 line
1.8.3.1
Re: [PATCH 2/2] nvme-loop: Fix memory leak in nvme_loop_create_ctrl()
Sent from my iPhone
Quoted 7 lines · Wu Bo
When creating loop ctrl in
nvme_loop_create_ctrl(), ifnvme_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.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Thanks,
applied to nvme-5.13 with slight tweaks to the commit messages and fixes tags.