Commit b84bb7bd authored by Ming Lei's avatar Ming Lei Committed by Keith Busch
Browse files

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 03b3bcd3 ("nvme: fix
admin request_queue lifetime").

Cc: Keith Busch <kbusch@kernel.org>
Fixes: 03b3bcd3 ("nvme: fix admin request_queue lifetime").
Reported-and-tested-by: default avatarYi Zhang <yi.zhang@redhat.com>
Closes: https://lore.kernel.org/linux-block/CAHj4cs9wv3SdPo+N01Fw2SHBYDs9tj2M_e1-GdQOkRy=DsBB1w@mail.gmail.com/


Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 0a1fc2f3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -4860,6 +4860,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_alloc_queue(set, &lim, NULL);
	if (IS_ERR(ctrl->admin_q)) {
		ret = PTR_ERR(ctrl->admin_q);