Skip to contentSkip to conversation

nvmet: fix memory leak on nvmet_alloc_ctrl()

PATCH In review Wu Bo 3 participants 4 messages May 18, 2021 – May 19, 2021

Subsystems (2)
lore
Share & tools
lore

Wu Bo

author
#0 lore raw

PATCH 1/1 nvmet: fix memory leak on nvmet_alloc_ctrl()

From: Wu Bo <[email protected]>

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")
---
 drivers/nvme/target/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/core.c +1 -1
index 25cc2ee8de3f..1853db38b682 100644
@@ -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
2.30.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Wu Bo
Quoted 11 lines · Wu Bo

From: Wu Bo <[email protected]>

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")

---

Looks good, except commit message could be better :-

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 6d65aeab7bf6 ("nvmet: remove unused ctrl->cqs")

with above :-

author
#3 lore raw
Quoted 19 lines · Chaitanya Kulkarni
Quoted 11 lines · Wu Bo

From: Wu Bo <[email protected]>

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")

---

Looks good, except commit message could be better :-

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().

Quoted 6 lines
Fixes 94a39d61f80f ("nvmet: make ctrl-id configurable")
Fixes 6d65aeab7bf6 ("nvmet: remove unused ctrl->cqs")

with above :-

Thanks for your review. I will make the commit message better. and I found the nvmet-loop has a similar issue,
will send patch series soon.

Thanks,
Wu Bo

Quoted 6 lines

.