Skip to contentSkip to conversation

nvme: fix admin queue leak on controller reset

PATCH Applied Ming Lei 3 participants 3 messages Jan 31 – Feb 2 NVMe

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 nvme: fix admin queue leak on controller reset

When nvme_alloc_admin_tag_set() is called during a controller reset, a previous admin queue may still exist. Release it properly before allocating a new one to avoid orphaning the old queue.

This fixes a regression introduced by commit 03b3bcd319b3 ("nvme: fix admin request_queue lifetime").

---
 drivers/nvme/host/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/nvme/host/core.c +9 -0
index 19b67cf5d550..4f1f460a6c11 100644
@@ -4865,6 +4865,15 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
 	if (ret)
 		return ret;
 
+	/*
+	 * If a previous admin queue exists (e.g., from before a reset),
+	 * put it now before allocating a new one to avoid orphaning it.
+	 */
+	if (ctrl->admin_q) {
+		blk_put_queue(ctrl->admin_q);
+		ctrl->admin_q = NULL;
+	}
+
 	ctrl->admin_q = blk_mq_alloc_queue(set, &lim, NULL);
 	if (IS_ERR(ctrl->admin_q)) {
 		ret = PTR_ERR(ctrl->admin_q);
Signature · 1 line
2.47.1
#1 lore raw
Quoted 24 lines · Ming Lei

When nvme_alloc_admin_tag_set() is called during a controller reset, a previous admin queue may still exist. Release it properly before allocating a new one to avoid orphaning the old queue.

This fixes a regression introduced by commit 03b3bcd319b3 ("nvme: fix admin request_queue lifetime").

---
 drivers/nvme/host/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/nvme/host/core.c +0 -0
index 19b67cf5d550..4f1f460a6c11 100644
@@ -4865,6 +4865,15 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
 	if (ret)
 		return ret;
 

drivers/nvme/host/core.c int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set, · line 4877

Quoted 10 lines
drivers/nvme/host/core.c +9 -0
+	/*
+	 * If a previous admin queue exists (e.g., from before a reset),
+	 * put it now before allocating a new one to avoid orphaning it.
+	 */
+	if (ctrl->admin_q) {
+		blk_put_queue(ctrl->admin_q);
+		ctrl->admin_q = NULL;
+	}
+
 	ctrl->admin_q = blk_mq_alloc_queue(set, &lim, NULL);

Clearing the admin_q to zero above is pointless given that it instantly gets overriden here. Otherwise this looks good.

maintainer Applied
#2 lore raw
In reply to Ming Lei
Quoted 6 lines · Ming Lei

When nvme_alloc_admin_tag_set() is called during a controller reset, a previous admin queue may still exist. Release it properly before allocating a new one to avoid orphaning the old queue.

This fixes a regression introduced by commit 03b3bcd319b3 ("nvme: fix admin request_queue lifetime").

Thanks, applied to nvme-7.0.