From: "Heyne, Maximilian" <mheyne@amazon.de>
To: "stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: "Heyne, Maximilian" <mheyne@amazon.de>,
Ming Lei <ming.lei@redhat.com>, Keith Busch <kbusch@kernel.org>,
Yi Zhang <yi.zhang@redhat.com>, Jens Axboe <axboe@kernel.dk>,
Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
"Christoph Hellwig" <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
"Avri Altman" <avri.altman@wdc.com>,
Bart Van Assche <bvanassche@acm.org>,
"Sasha Levin" <sashal@kernel.org>,
Peter Wang <peter.wang@mediatek.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
Seunghwan Baek <sh8267.baek@samsung.com>,
Seunghui Lee <sh043.lee@samsung.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
Brian Kao <powenkao@google.com>,
"Sanjeev Yadav" <sanjeev.y@mediatek.com>,
Wonkon Kim <wkon.kim@samsung.com>,
Chaitanya Kulkarni <kch@nvidia.com>,
Hannes Reinecke <hare@suse.de>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"asahi@lists.linux.dev" <asahi@lists.linux.dev>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Subject: [PATCH 6.1.y v2 6/6] nvme: fix admin queue leak on controller reset
Date: Thu, 2 Apr 2026 13:57:21 +0000 [thread overview]
Message-ID: <20260402-fox-attic-82ebf113@mheyne-amazon> (raw)
In-Reply-To: <20260402-moral-jockey-f072379b@mheyne-amazon>
From: Ming Lei <ming.lei@redhat.com>
[ Upstream commit b84bb7bd913d8ca2f976ee6faf4a174f91c02b8d ]
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>
Signed-off-by: Keith Busch <kbusch@kernel.org>
[ Have to do analogous work in nvme_pci_alloc_admin_tag_set in pci.c due
to missing upstream commit 0da7feaa5913 ("nvme-pci: use the tagset
alloc/free helpers") ]
Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
---
drivers/nvme/host/core.c | 7 +++++++
drivers/nvme/host/pci.c | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f17318f6c82b0..09439fa7d083a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -5012,6 +5012,13 @@ 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 = blk_mq_init_queue(set);
if (IS_ERR(ctrl->admin_q)) {
ret = PTR_ERR(ctrl->admin_q);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index e8b7b0004086c..07ca1e1d920b8 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1804,6 +1804,13 @@ static int nvme_pci_alloc_admin_tag_set(struct nvme_dev *dev)
return -ENOMEM;
dev->ctrl.admin_tagset = set;
+ /*
+ * 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 (dev->ctrl.admin_q)
+ blk_put_queue(dev->ctrl.admin_q);
+
dev->ctrl.admin_q = blk_mq_init_queue(set);
if (IS_ERR(dev->ctrl.admin_q)) {
blk_mq_free_tag_set(set);
--
2.50.1
Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
next prev parent reply other threads:[~2026-04-02 13:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 13:57 [PATCH 6.1.y v2 0/6] nvme: correctly fix admin request_queue lifetime Heyne, Maximilian
2026-04-02 13:57 ` [PATCH 6.1.y v2 1/6] Revert "nvme: fix admin request_queue lifetime" Heyne, Maximilian
2026-04-02 13:57 ` [PATCH 6.1.y v2 2/6] blk-mq: move the call to blk_put_queue out of blk_mq_destroy_queue Heyne, Maximilian
2026-04-02 13:57 ` [PATCH 6.1.y v2 3/6] nvme-pci: remove an extra queue reference Heyne, Maximilian
2026-04-02 13:57 ` [PATCH 6.1.y v2 4/6] nvme-pci: put the admin queue in nvme_dev_remove_admin Heyne, Maximilian
2026-04-02 13:57 ` [PATCH 6.1.y v2 5/6] nvme: fix admin request_queue lifetime Heyne, Maximilian
2026-04-02 13:57 ` Heyne, Maximilian [this message]
2026-04-03 9:43 ` [PATCH 6.1.y v2 6/6] nvme: fix admin queue leak on controller reset Fedor Pchelkin
2026-04-03 9:48 ` [PATCH 6.1.y v2 0/6] nvme: correctly fix admin request_queue lifetime Fedor Pchelkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260402-fox-attic-82ebf113@mheyne-amazon \
--to=mheyne@amazon.de \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=avri.altman@wdc.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=gregkh@linuxfoundation.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
--cc=peter.wang@mediatek.com \
--cc=powenkao@google.com \
--cc=sagi@grimberg.me \
--cc=sanjeev.y@mediatek.com \
--cc=sashal@kernel.org \
--cc=sh043.lee@samsung.com \
--cc=sh8267.baek@samsung.com \
--cc=stable@vger.kernel.org \
--cc=sven@svenpeter.dev \
--cc=wkon.kim@samsung.com \
--cc=yi.zhang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox