public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] nvme: fix admin queue leak on controller reset
@ 2026-01-31 14:48 Ming Lei
  2026-02-02  6:58 ` Christoph Hellwig
  2026-02-02 16:09 ` Keith Busch
  0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2026-01-31 14:48 UTC (permalink / raw)
  To: Christoph Hellwig, Keith Busch, linux-nvme; +Cc: Ming Lei, Yi Zhang

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

Cc: Keith Busch <kbusch@kernel.org>
Fixes: 03b3bcd319b3 ("nvme: fix admin request_queue lifetime").
Reported-and-tested-by: Yi Zhang <yi.zhang@redhat.com>
Closes: https://lore.kernel.org/linux-block/CAHj4cs9wv3SdPo+N01Fw2SHBYDs9tj2M_e1-GdQOkRy=DsBB1w@mail.gmail.com/
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/nvme/host/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 19b67cf5d550..4f1f460a6c11 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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);
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme: fix admin queue leak on controller reset
  2026-01-31 14:48 [PATCH] nvme: fix admin queue leak on controller reset Ming Lei
@ 2026-02-02  6:58 ` Christoph Hellwig
  2026-02-02 16:09 ` Keith Busch
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-02-02  6:58 UTC (permalink / raw)
  To: Ming Lei; +Cc: Christoph Hellwig, Keith Busch, linux-nvme, Yi Zhang

On Sat, Jan 31, 2026 at 10:48:08PM +0800, Ming Lei wrote:
> 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").
> 
> Cc: Keith Busch <kbusch@kernel.org>
> Fixes: 03b3bcd319b3 ("nvme: fix admin request_queue lifetime").
> Reported-and-tested-by: Yi Zhang <yi.zhang@redhat.com>
> Closes: https://lore.kernel.org/linux-block/CAHj4cs9wv3SdPo+N01Fw2SHBYDs9tj2M_e1-GdQOkRy=DsBB1w@mail.gmail.com/
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>  drivers/nvme/host/core.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 19b67cf5d550..4f1f460a6c11 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -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);

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme: fix admin queue leak on controller reset
  2026-01-31 14:48 [PATCH] nvme: fix admin queue leak on controller reset Ming Lei
  2026-02-02  6:58 ` Christoph Hellwig
@ 2026-02-02 16:09 ` Keith Busch
  1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2026-02-02 16:09 UTC (permalink / raw)
  To: Ming Lei; +Cc: Christoph Hellwig, linux-nvme, Yi Zhang

On Sat, Jan 31, 2026 at 10:48:08PM +0800, Ming Lei wrote:
> 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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-02 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31 14:48 [PATCH] nvme: fix admin queue leak on controller reset Ming Lei
2026-02-02  6:58 ` Christoph Hellwig
2026-02-02 16:09 ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox