From nobody Fri Apr 3 16:05:01 2026 Received: from iad-out-014.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-014.esa.us-east-1.outbound.mail-perimeter.amazon.com [50.16.246.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C2063DF00A; Thu, 2 Apr 2026 13:57:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=50.16.246.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138239; cv=none; b=WP6hIK+M7xdTZRs0BLHCU074G0AeTrn7Kl9kf/aGs3IRI4pHqg3DqoglhpEKDrm0jsDX6/Gcp8D1xe8yKtfzbPoDbH/22XhuQMoUczEAfkTTA4zruzNygZOfrzUhXh1V6OYqTqS6aVdC8lqUphQm3IcQ9U0TuDGM7ziCWkjvPiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138239; c=relaxed/simple; bh=s7wRlY/NElhgO0hzbPLkyqy9K97X1PSdyfsNpCekHmA=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=ptHl/wHNeavJG0+Wid+A5uBE7vuYQdmXS9VwshvQXJN4TBOzNOH13stUXTBUFI0fsJTjhRe+7k75WAhST3S1B0Iz04AGRZ5rJLbNUg6/REQcYa4ST4YoZ/j7KN9f9u9vzNCcSYrSLv6bRe/bLbCiRuiAAPWz5vv81UV+duyOeBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=qL42NneF; arc=none smtp.client-ip=50.16.246.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="qL42NneF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775138237; x=1806674237; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=dLVMAKqyGscpMd3RaTb0PTlAAEY6ecJ8SdxwSVZ0340=; b=qL42NneFFaMP2/Exz6MlPhiRaUX9exWQVMzD+SKwpCXjCMs3HSciB/O+ RK3Bfe0utwDDmA1gb9jsIdMeD1X1nTYdK4QG4ccg+J7EXPbSDXS4gt0It OkhwwT37SBdDAL4bwHb86VZXAsc0w6tX5veDuSZ5AEyojk6Ifp3IO+WaC ZRcxziCm/f7MJ8J+TZ8Mcd8PKA9ZH4QZMcTd4Ocyc7p3ZA+CQymZR0PCu BYi+Ah4rqOyh8GekgHY5JUqbPoVvbnOXqB1vqbQM+Y44iTAqpvUPtfahR KWUAFnImMZTnG6lj/TZ7zkZ70i1lufY6EfQYgN3zZLAipUf67cazJJG+T w==; X-CSE-ConnectionGUID: QefcKAD/QN21zgYZOMjGYg== X-CSE-MsgGUID: ryS+CPUiQOKO8fP8hRu9dw== X-IronPort-AV: E=Sophos;i="6.23,155,1770595200"; d="scan'208";a="14829490" Received: from ip-10-4-3-150.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.3.150]) by internal-iad-out-014.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2026 13:57:16 +0000 Received: from EX19MTAUEC002.ant.amazon.com [72.21.196.66:29020] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.56.32:2525] with esmtp (Farcaster) id e2ae4a7f-cdc7-4cfb-a244-584b549b0f48; Thu, 2 Apr 2026 13:57:15 +0000 (UTC) X-Farcaster-Flow-ID: e2ae4a7f-cdc7-4cfb-a244-584b549b0f48 Received: from EX19D012UEC003.ant.amazon.com (10.252.135.160) by EX19MTAUEC002.ant.amazon.com (10.252.135.253) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:14 +0000 Received: from EX19D012UEC003.ant.amazon.com (10.252.135.160) by EX19D012UEC003.ant.amazon.com (10.252.135.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:13 +0000 Received: from EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9]) by EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9%3]) with mapi id 15.02.2562.037; Thu, 2 Apr 2026 13:57:13 +0000 From: "Heyne, Maximilian" To: "stable@vger.kernel.org" CC: "Heyne, Maximilian" , Jens Axboe , Hector Martin , Sven Peter , "Alyssa Rosenzweig" , Keith Busch , Christoph Hellwig , Sagi Grimberg , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , "Avri Altman" , Bart Van Assche , "Sasha Levin" , Peter Wang , "Greg Kroah-Hartman" , Seunghwan Baek , Thomas Yen , Adrian Hunter , Wonkon Kim , Brian Kao , Seunghui Lee , Sanjeev Yadav , Hannes Reinecke , Ming Lei , Chaitanya Kulkarni , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "asahi@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-nvme@lists.infradead.org" , "linux-scsi@vger.kernel.org" Subject: [PATCH 6.1.y v2 1/6] Revert "nvme: fix admin request_queue lifetime" Thread-Topic: [PATCH 6.1.y v2 1/6] Revert "nvme: fix admin request_queue lifetime" Thread-Index: AQHcwqibkOh//WP2l0GMBmj+1Ehg9w== Date: Thu, 2 Apr 2026 13:57:13 +0000 Message-ID: <20260402-tavern-keen-2b4fa6b9@mheyne-amazon> References: <20260402-moral-jockey-f072379b@mheyne-amazon> In-Reply-To: <20260402-moral-jockey-f072379b@mheyne-amazon> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This reverts commit ff037b5f47eeccc1636c03f84cd47db094eb73c9. The backport of upstream commit 03b3bcd319b3 ("nvme: fix admin request_queue lifetime") to 6.1 is broken in 2 ways. First of all it doesn't actually fix the issue because blk_put_queue will still be called as part of blk_mq_destroy_queue in nvme_remove_admin_tag_set leading to the UAF. Second, the backport leads to a refcount underflow when unbinding a pci nvme device: refcount_t: underflow; use-after-free. WARNING: CPU: 2 PID: 1486 at lib/refcount.c:28 refcount_warn_saturate+0xba= /0x110 Modules linked in: bochs drm_vram_helper simpledrm skx_edac_common drm_shm= em_helper drm_kms_helper kvm_intel cfbfillrect syscopyarea cfbimgblt sysfil= lrect sysimgblt fb_sys_fops cfbcopyarea drm_ttm_helper fb ttm kvm fbdev drm= mousedev nls_ascii psmouse irqbypass nls_cp437 atkbd crc32_pclmul crc32c_i= ntel libps2 vfat fat sunrpc virtio_net ata_piix vivaldi_fmap drm_panel_orie= ntation_quirks libata backlight i2c_piix4 net_failover i8042 ghash_clmulni_= intel failover serio i2c_core button sch_fq_codel CPU: 2 PID: 1486 Comm: bash Not tainted 6.1.167 #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS edk2-20240813-= 306.amzn2 08/13/2024 RIP: 0010:refcount_warn_saturate+0xba/0x110 Code: 01 01 e8 89 79 ad ff 0f 0b e9 82 f4 7e 00 80 3d 73 03 cc 01 00 75 85= 48 c7 c7 e0 5d 3b 8e c6 05 63 03 cc 01 01 e8 66 79 ad ff <0f> 0b c3 cc cc = cc cc 80 3d 4e 03 cc 01 00 0f 85 5e ff ff ff 48 c7 RSP: 0018:ffffd0cc011bfd18 EFLAGS: 00010286 RAX: 0000000000000000 RBX: ffff8ada07b33210 RCX: 0000000000000027 RDX: ffff8adb37d1f728 RSI: 0000000000000001 RDI: ffff8adb37d1f720 RBP: ffff8ada07b33000 R08: 0000000000000000 R09: 00000000fffeffff R10: ffffd0cc011bfba8 R11: ffffffff8f1781a8 R12: ffffd0cc011bfd38 R13: ffff8ada03080800 R14: ffff8ada07b33210 R15: ffff8ada07b33b10 FS: 00007f50f6964740(0000) GS:ffff8adb37d00000(0000) knlGS:00000000000000= 00 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055cdb54e6ae0 CR3: 000000010224e001 CR4: 0000000000770ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: nvme_pci_free_ctrl+0x45/0x80 nvme_free_ctrl+0x1aa/0x2b0 device_release+0x34/0x90 kobject_cleanup+0x3a/0x130 pci_device_remove+0x3e/0xb0 device_release_driver_internal+0x1aa/0x230 unbind_store+0x11f/0x130 kernfs_fop_write_iter+0x13a/0x1d0 vfs_write+0x2a6/0x3b0 ksys_write+0x5f/0xe0 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x6e/0xd8 RIP: 0033:0x7f50f66ff897 Code: 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa= 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff = ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24 RSP: 002b:00007fffaef903d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f50f67fd780 RCX: 00007f50f66ff897 RDX: 000000000000000d RSI: 0000557f72ef6b90 RDI: 0000000000000001 RBP: 000000000000000d R08: 0000000000000000 R09: 00007f50f67b2d20 R10: 00007f50f67b2c20 R11: 0000000000000246 R12: 000000000000000d R13: 0000557f72ef6b90 R14: 000000000000000d R15: 00007f50f67f89c0 The reason for this is that nvme_free_ctrl calls ->free_ctrl which resolves to nvme_pci_free_ctrl in aforementioned case which also has a blk_put_queue, so the admin queue is put twice. This is because on 6.1 we're missing the commit 96ef1be53663 ("nvme-pci: put the admin queue in nvme_dev_remove_admin"). Signed-off-by: Maximilian Heyne Tested-by: Fedor Pchelkin --- drivers/nvme/host/core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 9df33b293ee3e..938af571dc13e 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -5180,8 +5180,6 @@ static void nvme_free_ctrl(struct device *dev) container_of(dev, struct nvme_ctrl, ctrl_device); struct nvme_subsystem *subsys =3D ctrl->subsys; =20 - if (ctrl->admin_q) - blk_put_queue(ctrl->admin_q); if (!subsys || ctrl->instance !=3D subsys->instance) ida_free(&nvme_instance_ida, ctrl->instance); =20 --=20 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 From nobody Fri Apr 3 16:05:01 2026 Received: from iad-out-014.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-014.esa.us-east-1.outbound.mail-perimeter.amazon.com [50.16.246.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06CCF3DEAF0; Thu, 2 Apr 2026 13:57:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=50.16.246.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138242; cv=none; b=up9Vin4lcxNwHgcybF/asYdQXMTrfvgYbJNLsFdsEm/8ZcghTomnHposB6EOyeTKFmyTRF75FcGsg2PYlbrKfo7eOw6VuES2EZbHlzP3XnLvSZYm7FGGqEmdtgTnYXUpZul8Ikn4bQ5x9uu51XcJX6ZxvtbmNdqJ7sPbq0vT4VM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138242; c=relaxed/simple; bh=vpq4nB3qwZzEF+4p6P592kZd1o2sPQZYwp9+15SRk2E=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=p6UpOgEzP1/1sUGjL4rTCZLHciLlhbRnwe+w4oabSpQ0xjYJ8J2bdqZmxtFyr8NIZWGeT8XGiKr7X0IiGaZLau2I1BgarOG/tsR/J+1F9AhHQZx3C00oDez6yC1P9Rgqkniir9HLCmajY6UWIK9tLNbuhSyCBiO4GFdT0SEOpzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=M9WiyQjA; arc=none smtp.client-ip=50.16.246.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="M9WiyQjA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775138240; x=1806674240; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=WXQBh+3u+MJvhba/wycvWbO/cH1qS5tV/vhN0sfRQX4=; b=M9WiyQjAK+5IHGZtjUg7HWxOZF83eCgoG7JprSKB76CV00U6ytaLFX3C lpHCrIgLUaC70C4tKLeuCcz0A+z+KALmeXNBZdKmdJdIm3tReX/Q/2zDt rgTQ/9oObOBg2RBHT3EXM9gei7bmEdlt/+WqqQCuEOzTKM6pR7cIxeVsu CCcPnnUUlbtksGMscmYuBdUQ+y4SZlZDXFlZMKP0fT9euC1xeHlEIO8Tx sEIVpzajtttHRgG0vKOpsQRnT+Qa1UQt47wAuTAQkJtjpKOltLFiLC7Xt eNOWGFA1VxmB0HkU33McHci5AQSKpzcve7wT4A/ZmPXhEmzNLy9M2a4dH w==; X-CSE-ConnectionGUID: 6EE9QzjYSfSvXrwAMhe2Vw== X-CSE-MsgGUID: Dc/I/MAIT/OUT1pEzlTaXg== X-IronPort-AV: E=Sophos;i="6.23,155,1770595200"; d="scan'208";a="14829491" Received: from ip-10-4-3-150.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.3.150]) by internal-iad-out-014.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2026 13:57:16 +0000 Received: from EX19MTAUEC001.ant.amazon.com [52.94.133.134:3493] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.12.35:2525] with esmtp (Farcaster) id 1f5fa28a-0598-48c2-a506-36b920804b66; Thu, 2 Apr 2026 13:57:16 +0000 (UTC) X-Farcaster-Flow-ID: 1f5fa28a-0598-48c2-a506-36b920804b66 Received: from EX19D012UEC004.ant.amazon.com (10.252.135.219) by EX19MTAUEC001.ant.amazon.com (10.252.135.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:15 +0000 Received: from EX19D012UEC003.ant.amazon.com (10.252.135.160) by EX19D012UEC004.ant.amazon.com (10.252.135.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:15 +0000 Received: from EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9]) by EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9%3]) with mapi id 15.02.2562.037; Thu, 2 Apr 2026 13:57:15 +0000 From: "Heyne, Maximilian" To: "stable@vger.kernel.org" CC: "Heyne, Maximilian" , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , "Keith Busch" , Jens Axboe , Hector Martin , Sven Peter , Alyssa Rosenzweig , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , Avri Altman , Bart Van Assche , Sasha Levin , Peter Wang , Greg Kroah-Hartman , Adrian Hunter , Thomas Yen , Brian Kao , Seunghui Lee , Sanjeev Yadav , Wonkon Kim , Ming Lei , Hannes Reinecke , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "asahi@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-nvme@lists.infradead.org" , "linux-scsi@vger.kernel.org" Subject: [PATCH 6.1.y v2 2/6] blk-mq: move the call to blk_put_queue out of blk_mq_destroy_queue Thread-Topic: [PATCH 6.1.y v2 2/6] blk-mq: move the call to blk_put_queue out of blk_mq_destroy_queue Thread-Index: AQHcwqich41sprKN6EWvyx0ADvz7kg== Date: Thu, 2 Apr 2026 13:57:15 +0000 Message-ID: <20260402-model-paradox-ae8cef60@mheyne-amazon> References: <20260402-moral-jockey-f072379b@mheyne-amazon> In-Reply-To: <20260402-moral-jockey-f072379b@mheyne-amazon> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Christoph Hellwig [ Upstream commit 2b3f056f72e56fa07df69b4705e0b46a6c08e77c ] The fact that blk_mq_destroy_queue also drops a queue reference leads to various places having to grab an extra reference. Move the call to blk_put_queue into the callers to allow removing the extra references. Signed-off-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni Reviewed-by: Keith Busch Link: https://lore.kernel.org/r/20221018135720.670094-2-hch@lst.de [axboe: fix fabrics_q vs admin_q conflict in nvme core.c] Signed-off-by: Jens Axboe Stable-dep-of: 03b3bcd319b3 ("nvme: fix admin request_queue lifetime") Signed-off-by: Maximilian Heyne Tested-by: Fedor Pchelkin --- block/blk-mq.c | 4 +--- block/bsg-lib.c | 2 ++ drivers/nvme/host/apple.c | 1 + drivers/nvme/host/core.c | 10 ++++++++-- drivers/nvme/host/pci.c | 1 + drivers/scsi/scsi_sysfs.c | 1 + drivers/ufs/core/ufshcd.c | 2 ++ 7 files changed, 16 insertions(+), 5 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index a9697541d67f9..8b9e5ca398242 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4194,9 +4194,6 @@ void blk_mq_destroy_queue(struct request_queue *q) blk_sync_queue(q); blk_mq_cancel_work_sync(q); blk_mq_exit_queue(q); - - /* @q is and will stay empty, shutdown and put */ - blk_put_queue(q); } EXPORT_SYMBOL(blk_mq_destroy_queue); =20 @@ -4213,6 +4210,7 @@ struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag= _set *set, void *queuedata, disk =3D __alloc_disk_node(q, set->numa_node, lkclass); if (!disk) { blk_mq_destroy_queue(q); + blk_put_queue(q); return ERR_PTR(-ENOMEM); } set_bit(GD_OWNS_QUEUE, &disk->state); diff --git a/block/bsg-lib.c b/block/bsg-lib.c index d6f5dcdce748c..435c32373cd68 100644 --- a/block/bsg-lib.c +++ b/block/bsg-lib.c @@ -325,6 +325,7 @@ void bsg_remove_queue(struct request_queue *q) =20 bsg_unregister_queue(bset->bd); blk_mq_destroy_queue(q); + blk_put_queue(q); blk_mq_free_tag_set(&bset->tag_set); kfree(bset); } @@ -400,6 +401,7 @@ struct request_queue *bsg_setup_queue(struct device *de= v, const char *name, return q; out_cleanup_queue: blk_mq_destroy_queue(q); + blk_put_queue(q); out_queue: blk_mq_free_tag_set(set); out_tag_set: diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c index 262d2b60ac6dd..c5fc293c22123 100644 --- a/drivers/nvme/host/apple.c +++ b/drivers/nvme/host/apple.c @@ -1510,6 +1510,7 @@ static int apple_nvme_probe(struct platform_device *p= dev) if (!blk_get_queue(anv->ctrl.admin_q)) { nvme_start_admin_queue(&anv->ctrl); blk_mq_destroy_queue(anv->ctrl.admin_q); + blk_put_queue(anv->ctrl.admin_q); anv->ctrl.admin_q =3D NULL; ret =3D -ENODEV; goto put_dev; diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 938af571dc13e..044e1a9c099b3 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -5031,6 +5031,7 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, = struct blk_mq_tag_set *set, =20 out_cleanup_admin_q: blk_mq_destroy_queue(ctrl->admin_q); + blk_put_queue(ctrl->admin_q); out_free_tagset: blk_mq_free_tag_set(set); ctrl->admin_q =3D NULL; @@ -5042,8 +5043,11 @@ EXPORT_SYMBOL_GPL(nvme_alloc_admin_tag_set); void nvme_remove_admin_tag_set(struct nvme_ctrl *ctrl) { blk_mq_destroy_queue(ctrl->admin_q); - if (ctrl->ops->flags & NVME_F_FABRICS) + blk_put_queue(ctrl->admin_q); + if (ctrl->ops->flags & NVME_F_FABRICS) { blk_mq_destroy_queue(ctrl->fabrics_q); + blk_put_queue(ctrl->fabrics_q); + } blk_mq_free_tag_set(ctrl->admin_tagset); } EXPORT_SYMBOL_GPL(nvme_remove_admin_tag_set); @@ -5099,8 +5103,10 @@ EXPORT_SYMBOL_GPL(nvme_alloc_io_tag_set); =20 void nvme_remove_io_tag_set(struct nvme_ctrl *ctrl) { - if (ctrl->ops->flags & NVME_F_FABRICS) + if (ctrl->ops->flags & NVME_F_FABRICS) { blk_mq_destroy_queue(ctrl->connect_q); + blk_put_queue(ctrl->connect_q); + } blk_mq_free_tag_set(ctrl->tagset); } EXPORT_SYMBOL_GPL(nvme_remove_io_tag_set); diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 518f8c5012bdf..727585f580362 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1782,6 +1782,7 @@ static void nvme_dev_remove_admin(struct nvme_dev *de= v) */ nvme_start_admin_queue(&dev->ctrl); blk_mq_destroy_queue(dev->ctrl.admin_q); + blk_put_queue(dev->ctrl.admin_q); blk_mq_free_tag_set(&dev->admin_tagset); } } diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 456b92c3a7811..af81b2ba0c9b3 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -1486,6 +1486,7 @@ void __scsi_remove_device(struct scsi_device *sdev) mutex_unlock(&sdev->state_mutex); =20 blk_mq_destroy_queue(sdev->request_queue); + blk_put_queue(sdev->request_queue); kref_put(&sdev->host->tagset_refcnt, scsi_mq_free_tags); cancel_work_sync(&sdev->requeue_work); =20 diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index f72ba0b206437..a39ffc62d88a1 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -9651,6 +9651,7 @@ void ufshcd_remove(struct ufs_hba *hba) ufshpb_remove(hba); ufs_sysfs_remove_nodes(hba->dev); blk_mq_destroy_queue(hba->tmf_queue); + blk_put_queue(hba->tmf_queue); blk_mq_free_tag_set(&hba->tmf_tag_set); scsi_remove_host(hba->host); /* disable interrupts */ @@ -9953,6 +9954,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mm= io_base, unsigned int irq) =20 free_tmf_queue: blk_mq_destroy_queue(hba->tmf_queue); + blk_put_queue(hba->tmf_queue); free_tmf_tag_set: blk_mq_free_tag_set(&hba->tmf_tag_set); out_remove_scsi_host: --=20 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 From nobody Fri Apr 3 16:05:01 2026 Received: from iad-out-011.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-011.esa.us-east-1.outbound.mail-perimeter.amazon.com [54.211.126.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DCF03E4C74; Thu, 2 Apr 2026 13:57:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.211.126.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138243; cv=none; b=HbP7mfgTvTz2dKeipPLZNTzjfYTerB9QLsXxcIqjzXIwuTQ68DFb3B0Vth/YlogcgiZkcjbndFFKRhzsNIkbDc2WaUOXjF2SBg6/89g6MNEtfEA2tdcbau1kDA6+7WmJQfCXNi2Isgke5L3i//wK8sGKsLoxA0aouQnLZ6nd60E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138243; c=relaxed/simple; bh=1+WHPwcQvkrDqjN7jtha7n2OLLRrBtkNbbXM9KBS+Vk=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=liOckUgTqDSMLDS+maRvpI4Bo4o5vNe5Jt5mwRLb63gjtIWlgTot12ZXlObNVioobo9Mbs72HdG7E/6hySOtB0k1QvbN4V2RKXhzL6Ugq92eztEn0ZmXfUXA299gPWswbKfZe9iHkUobT0Tv0cZaoq81ZBH+By1vp/oaP+sc84U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=EDNHvxwr; arc=none smtp.client-ip=54.211.126.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="EDNHvxwr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775138241; x=1806674241; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=wuthZuZJNuIVCbef4TvR92fybPm79mBQ8LikDhPWnf0=; b=EDNHvxwrbLXz+qGlkPgo9zRC3f5SmEDBrzuZAzM72EFAITDS63I24f2X 2IiyI4t3xQ+zlYVbWkOtPTXe/OY7ODBLgLGRNyYj1ApdE70PnMUq4EURH iJ2mXXq/x0SC9INAlhPpyHZ3WtVOueZr6PQOUd0AqLuFw2/VqnruRmqhI Ev0KiAI+tuHQjvrurZBo4pcgSNS7FJj6zGARVPBjZzDiO+EmoEn1OjCrG A/tRT8wN8PXrXxgaYROWqkUtI4h4Ig7yNgWUMZgIPrJgryKdm0uKXqwAB A/gLphG5Df6yvOxGTTmUJOkHsoneoMLVvdqdmfX80VnVpLdWO9ACqK+Mh g==; X-CSE-ConnectionGUID: wmue6bv0TJ6AjraC9JMWAw== X-CSE-MsgGUID: +gr5tpNzQMafIjWemEgWdA== X-IronPort-AV: E=Sophos;i="6.23,155,1770595200"; d="scan'208";a="15265777" Received: from ip-10-4-3-150.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.3.150]) by internal-iad-out-011.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2026 13:57:17 +0000 Received: from EX19MTAUEC001.ant.amazon.com [52.94.133.134:1848] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.95.220:2525] with esmtp (Farcaster) id 5af4ab1e-2771-496a-a456-0cc6e54b38d6; Thu, 2 Apr 2026 13:57:17 +0000 (UTC) X-Farcaster-Flow-ID: 5af4ab1e-2771-496a-a456-0cc6e54b38d6 Received: from EX19D012UEC001.ant.amazon.com (10.252.135.206) by EX19MTAUEC001.ant.amazon.com (10.252.135.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:17 +0000 Received: from EX19D012UEC003.ant.amazon.com (10.252.135.160) by EX19D012UEC001.ant.amazon.com (10.252.135.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:16 +0000 Received: from EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9]) by EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9%3]) with mapi id 15.02.2562.037; Thu, 2 Apr 2026 13:57:16 +0000 From: "Heyne, Maximilian" To: "stable@vger.kernel.org" CC: "Heyne, Maximilian" , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , "Keith Busch" , Jens Axboe , Hector Martin , Sven Peter , Alyssa Rosenzweig , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , Avri Altman , Bart Van Assche , Sasha Levin , Peter Wang , Greg Kroah-Hartman , Sanjeev Yadav , Adrian Hunter , Seunghwan Baek , "Brian Kao" , Seunghui Lee , Wonkon Kim , Hannes Reinecke , Ming Lei , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "asahi@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-nvme@lists.infradead.org" , "linux-scsi@vger.kernel.org" Subject: [PATCH 6.1.y v2 3/6] nvme-pci: remove an extra queue reference Thread-Topic: [PATCH 6.1.y v2 3/6] nvme-pci: remove an extra queue reference Thread-Index: AQHcwqid6cK14LT21EWoDH9t6D61vA== Date: Thu, 2 Apr 2026 13:57:16 +0000 Message-ID: <20260402-virtual-london-e865225a@mheyne-amazon> References: <20260402-moral-jockey-f072379b@mheyne-amazon> In-Reply-To: <20260402-moral-jockey-f072379b@mheyne-amazon> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Christoph Hellwig [ Upstream commit 7dcebef90d35de13a326f765dd787538880566f9 ] Now that blk_mq_destroy_queue does not release the queue reference, there is no need for a second admin queue reference to be held by the nvme_dev. Signed-off-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni Reviewed-by: Keith Busch Link: https://lore.kernel.org/r/20221018135720.670094-4-hch@lst.de Signed-off-by: Jens Axboe Stable-dep-of: 03b3bcd319b3 ("nvme: fix admin request_queue lifetime") Signed-off-by: Maximilian Heyne Tested-by: Fedor Pchelkin --- drivers/nvme/host/pci.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 727585f580362..13c0098939ec0 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1782,7 +1782,6 @@ static void nvme_dev_remove_admin(struct nvme_dev *de= v) */ nvme_start_admin_queue(&dev->ctrl); blk_mq_destroy_queue(dev->ctrl.admin_q); - blk_put_queue(dev->ctrl.admin_q); blk_mq_free_tag_set(&dev->admin_tagset); } } @@ -1811,11 +1810,6 @@ static int nvme_pci_alloc_admin_tag_set(struct nvme_= dev *dev) dev->ctrl.admin_q =3D NULL; return -ENOMEM; } - if (!blk_get_queue(dev->ctrl.admin_q)) { - nvme_dev_remove_admin(dev); - dev->ctrl.admin_q =3D NULL; - return -ENODEV; - } return 0; } =20 --=20 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 From nobody Fri Apr 3 16:05:01 2026 Received: from iad-out-006.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-006.esa.us-east-1.outbound.mail-perimeter.amazon.com [3.216.221.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 681C13E9595; Thu, 2 Apr 2026 13:57:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.216.221.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138245; cv=none; b=C4nXIQuBZHKLOmmCLL/4ru88A2PgQj/rKppQOmg9gw5A96cHIErHU6m+EwK1ZntYZh1klY6J9yDEzwKZVJzwCvVsQuULScyfiZfBUkZ6tIlZ8mfDipeNxD0n7dhdIUDFoXJRafcr7/GolO9rrIVteg47QwGnuO6Zjamp8hffUV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138245; c=relaxed/simple; bh=Qrk8GSV96kDDkq1+0VAMC53OBa1WpEWTZeLl1slKnmA=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=Ud7HhjDgGVpJuFKC1PhYkv0esCkVbqi8EX3yfcw9y5TvQPDu9KC/FfFShJE38+28PIjb4sHySyUOgk0YcNU7XrhmSC7wBBopnctcGh466GG2DxeVjIixeMGft5fhaOqF0faLawp8xxixqJVfapX7JdRboeqOWkEZK5SQqiNFG0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=Eev2BELo; arc=none smtp.client-ip=3.216.221.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="Eev2BELo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775138243; x=1806674243; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=yyrWPY5Ev1YqXQNI936Pi4tZz7GWIXsbdLr6GEho4RU=; b=Eev2BELoZcSDLvIKBqGYG7n5LTYfqeSvYf36uoWCgDn62EBA+V0SeLYz WHoIF8GDPBLpwO0AIPSkOqTWac1CvmEeH7npNYrBDEURdh5CB6ITwrD/N IjG2E0FntkM645CgLsGwI1vVqW7dgAMrT+NEI5G9lyDcDUCmgkBR+UYVU 7gJPnKSVo/S1bfXS/yCkUfHIueOtL4YrJyXOv8GYQsivJF9tQkaKakrGI fX6nIw1QB1hMZW8SFUVKWD2imbZSspGgY61Ohi190zAqBJY79tDl9qsUZ E3ddWYWMAqlSASfaum0xK8cRk6eY9F9ROxY2yKBDHxEfFsZR6iLyDNzRI w==; X-CSE-ConnectionGUID: cCuUAN+OQB2K6u5cvFpdWA== X-CSE-MsgGUID: CBI+7n0xSMyKsLNmLVjrTA== X-IronPort-AV: E=Sophos;i="6.23,155,1770595200"; d="scan'208";a="15383184" Received: from ip-10-4-17-41.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.17.41]) by internal-iad-out-006.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2026 13:57:19 +0000 Received: from EX19MTAUEB002.ant.amazon.com [52.94.133.143:5141] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.39.103:2525] with esmtp (Farcaster) id 68d3bac5-7a3e-4487-90d4-822c0b579f99; Thu, 2 Apr 2026 13:57:19 +0000 (UTC) X-Farcaster-Flow-ID: 68d3bac5-7a3e-4487-90d4-822c0b579f99 Received: from EX19D012UEC002.ant.amazon.com (10.252.135.254) by EX19MTAUEB002.ant.amazon.com (10.252.135.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:18 +0000 Received: from EX19D012UEC003.ant.amazon.com (10.252.135.160) by EX19D012UEC002.ant.amazon.com (10.252.135.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:18 +0000 Received: from EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9]) by EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9%3]) with mapi id 15.02.2562.037; Thu, 2 Apr 2026 13:57:18 +0000 From: "Heyne, Maximilian" To: "stable@vger.kernel.org" CC: "Heyne, Maximilian" , Christoph Hellwig , Keith Busch , Sagi Grimberg , "Chaitanya Kulkarni" , Jens Axboe , Hector Martin , Sven Peter , Alyssa Rosenzweig , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , Avri Altman , Bart Van Assche , Sasha Levin , Peter Wang , Greg Kroah-Hartman , Thomas Yen , Brian Kao , "Sanjeev Yadav" , Wonkon Kim , "Seunghui Lee" , Ming Lei , Hannes Reinecke , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "asahi@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-nvme@lists.infradead.org" , "linux-scsi@vger.kernel.org" Subject: [PATCH 6.1.y v2 4/6] nvme-pci: put the admin queue in nvme_dev_remove_admin Thread-Topic: [PATCH 6.1.y v2 4/6] nvme-pci: put the admin queue in nvme_dev_remove_admin Thread-Index: AQHcwqieIRJTxL3DvEmKk95Z3tjcyQ== Date: Thu, 2 Apr 2026 13:57:18 +0000 Message-ID: <20260402-kemp-dime-b84f5127@mheyne-amazon> References: <20260402-moral-jockey-f072379b@mheyne-amazon> In-Reply-To: <20260402-moral-jockey-f072379b@mheyne-amazon> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Christoph Hellwig [ Upstream commit 96ef1be53663a9343dffcf106e2f1b59da4b8799 ] Once the controller is shutdown no one can access the admin queue. Tear it down in nvme_dev_remove_admin, which matches the flow in the other drivers. Signed-off-by: Christoph Hellwig Reviewed-by: Keith Busch Reviewed-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni Tested-by Gerd Bayer Stable-dep-of: 03b3bcd319b3 ("nvme: fix admin request_queue lifetime") [ Context change due to missing commit 94cc781f69f4 ("nvme: move OPAL setup from PCIe to core")] Signed-off-by: Maximilian Heyne Tested-by Gerd Bayer Tested-by: Fedor Pchelkin --- drivers/nvme/host/pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 13c0098939ec0..38732c0c28bbb 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1782,6 +1782,7 @@ static void nvme_dev_remove_admin(struct nvme_dev *de= v) */ nvme_start_admin_queue(&dev->ctrl); blk_mq_destroy_queue(dev->ctrl.admin_q); + blk_put_queue(dev->ctrl.admin_q); blk_mq_free_tag_set(&dev->admin_tagset); } } @@ -2831,8 +2832,6 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl) =20 nvme_dbbuf_dma_free(dev); nvme_free_tagset(dev); - if (dev->ctrl.admin_q) - blk_put_queue(dev->ctrl.admin_q); free_opal_dev(dev->ctrl.opal_dev); mempool_destroy(dev->iod_mempool); put_device(dev->dev); --=20 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 From nobody Fri Apr 3 16:05:01 2026 Received: from iad-out-001.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-001.esa.us-east-1.outbound.mail-perimeter.amazon.com [107.22.191.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB9CF3EAC7D; Thu, 2 Apr 2026 13:57:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=107.22.191.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138246; cv=none; b=l8L7+Mh1LLrLOBnr3vb3CfB8QYkCjWPaBNoZu6V4uX7T+7YK93F0dCoiFFlhGRPJbmPaLbpUFf06qDWQgx9krFpVdqLsEEsJ6uL3smn0Ccz+VhzCEjDiiVIkgQdD4ZRfrbj6lBo/9qWBmp978m7bdguU7mFBKQApQNVYQ59R9mo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138246; c=relaxed/simple; bh=JG2Mv9KfI7xkq43R9tTrX6gyZeNUTJ68NxGSnZETtNU=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=P08VRjxl6lHJhyA0wVhmqkXUEtdcTTIeES54Yc+NnkPkvXUW9xBdkPY/ivOzkefgBNQRNnD/eMROn1pZva5BZU8mz/tFZl/5pq8/A9gHeCih3tsffgnuzlItIahImFpp11EdIwb2i2WlNsABcgyI80Fyvew52X4LsgqBBrk3DIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=tlghinag; arc=none smtp.client-ip=107.22.191.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="tlghinag" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775138245; x=1806674245; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=uP5c6JzjwZwnGCsqflyTr1RQBZf98/zHqoDjD1LVIe8=; b=tlghinagVkaxpxVfZfAxysM9soN/XJ5BPs+HhdvtQM1zd9O65z+5bYki 0nWPnNYPBoupnADfdJ8AkGHMN4cvdtEGHiL9Otst9UM0YeLot7Lh01wSC 0bntyFUvbmSQblrs9USBk1DFRBC8ImWJf4Dyj0EbHGL4GwvQx+yZycgca 7L0R1YTjB+AfCxfrWPXYvoGuVmUokD+sAAyKIfOZ09rQwm2bU+uoNwOzC SkFWyYg1qx/nkaMTSyLnlBACcH5eaBTko75NDyvimaeMGOei+7eS7mvPN fF8Mw8HKvfOLWhBOQBfqUa6dWZaS6fxdcaBbrljNTqTyBS7ivNQMJFVGP w==; X-CSE-ConnectionGUID: NdtHOC2/QUC71siKA+aOaw== X-CSE-MsgGUID: rByC0p3/S0qrlGbYKmvOyw== X-IronPort-AV: E=Sophos;i="6.23,155,1770595200"; d="scan'208";a="14926256" Received: from ip-10-4-22-235.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.22.235]) by internal-iad-out-001.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2026 13:57:20 +0000 Received: from EX19MTAUEB002.ant.amazon.com [52.94.133.143:22502] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.17.255:2525] with esmtp (Farcaster) id 31a3c434-4697-4e89-8051-95e7f182a31b; Thu, 2 Apr 2026 13:57:20 +0000 (UTC) X-Farcaster-Flow-ID: 31a3c434-4697-4e89-8051-95e7f182a31b Received: from EX19D012UEC004.ant.amazon.com (10.252.135.219) by EX19MTAUEB002.ant.amazon.com (10.252.135.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:20 +0000 Received: from EX19D012UEC003.ant.amazon.com (10.252.135.160) by EX19D012UEC004.ant.amazon.com (10.252.135.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:20 +0000 Received: from EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9]) by EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9%3]) with mapi id 15.02.2562.037; Thu, 2 Apr 2026 13:57:20 +0000 From: "Heyne, Maximilian" To: "stable@vger.kernel.org" CC: "Heyne, Maximilian" , Keith Busch , Casey Chen , Christoph Hellwig , "Hannes Reinecke" , Ming Lei , Chaitanya Kulkarni , Jens Axboe , Hector Martin , Sven Peter , Alyssa Rosenzweig , Sagi Grimberg , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , "Avri Altman" , Bart Van Assche , "Sasha Levin" , Peter Wang , "Greg Kroah-Hartman" , Thomas Yen , Bean Huo , Seunghwan Baek , Brian Kao , Seunghui Lee , Sanjeev Yadav , Wonkon Kim , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "asahi@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-nvme@lists.infradead.org" , "linux-scsi@vger.kernel.org" Subject: [PATCH 6.1.y v2 5/6] nvme: fix admin request_queue lifetime Thread-Topic: [PATCH 6.1.y v2 5/6] nvme: fix admin request_queue lifetime Thread-Index: AQHcwqifs3Nc8vl5p0q1jggWcESD2A== Date: Thu, 2 Apr 2026 13:57:19 +0000 Message-ID: <20260402-sloth-visible-3c249ba7@mheyne-amazon> References: <20260402-moral-jockey-f072379b@mheyne-amazon> In-Reply-To: <20260402-moral-jockey-f072379b@mheyne-amazon> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Keith Busch [ Upstream commit 03b3bcd319b3ab5182bc9aaa0421351572c78ac0] The namespaces can access the controller's admin request_queue, and stale references on the namespaces may exist after tearing down the controller. Ensure the admin request_queue is active by moving the controller's 'put' to after all controller references have been released to ensure no one is can access the request_queue. This fixes a reported use-after-free bug: BUG: KASAN: slab-use-after-free in blk_queue_enter+0x41c/0x4a0 Read of size 8 at addr ffff88c0a53819f8 by task nvme/3287 CPU: 67 UID: 0 PID: 3287 Comm: nvme Tainted: G E 6.13.2-= ga1582f1a031e #15 Tainted: [E]=3DUNSIGNED_MODULE Hardware name: Jabil /EGS 2S MB1, BIOS 1.00 06/18/2025 Call Trace: dump_stack_lvl+0x4f/0x60 print_report+0xc4/0x620 ? _raw_spin_lock_irqsave+0x70/0xb0 ? _raw_read_unlock_irqrestore+0x30/0x30 ? blk_queue_enter+0x41c/0x4a0 kasan_report+0xab/0xe0 ? blk_queue_enter+0x41c/0x4a0 blk_queue_enter+0x41c/0x4a0 ? __irq_work_queue_local+0x75/0x1d0 ? blk_queue_start_drain+0x70/0x70 ? irq_work_queue+0x18/0x20 ? vprintk_emit.part.0+0x1cc/0x350 ? wake_up_klogd_work_func+0x60/0x60 blk_mq_alloc_request+0x2b7/0x6b0 ? __blk_mq_alloc_requests+0x1060/0x1060 ? __switch_to+0x5b7/0x1060 nvme_submit_user_cmd+0xa9/0x330 nvme_user_cmd.isra.0+0x240/0x3f0 ? force_sigsegv+0xe0/0xe0 ? nvme_user_cmd64+0x400/0x400 ? vfs_fileattr_set+0x9b0/0x9b0 ? cgroup_update_frozen_flag+0x24/0x1c0 ? cgroup_leave_frozen+0x204/0x330 ? nvme_ioctl+0x7c/0x2c0 blkdev_ioctl+0x1a8/0x4d0 ? blkdev_common_ioctl+0x1930/0x1930 ? fdget+0x54/0x380 __x64_sys_ioctl+0x129/0x190 do_syscall_64+0x5b/0x160 entry_SYSCALL_64_after_hwframe+0x4b/0x53 RIP: 0033:0x7f765f703b0b Code: ff ff ff 85 c0 79 9b 49 c7 c4 ff ff ff ff 5b 5d 4c 89 e0 41 5c c3 6= 6 0f 1f 84 00 00 00 00 00 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff= ff 73 01 c3 48 8b 0d dd 52 0f 00 f7 d8 64 89 01 48 RSP: 002b:00007ffe2cefe808 EFLAGS: 00000202 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007ffe2cefe860 RCX: 00007f765f703b0b RDX: 00007ffe2cefe860 RSI: 00000000c0484e41 RDI: 0000000000000003 RBP: 0000000000000000 R08: 0000000000000003 R09: 0000000000000000 R10: 00007f765f611d50 R11: 0000000000000202 R12: 0000000000000003 R13: 00000000c0484e41 R14: 0000000000000001 R15: 00007ffe2cefea60 Reported-by: Casey Chen Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Reviewed-by: Ming Lei Reviewed-by: Chaitanya Kulkarni Signed-off-by: Keith Busch [ Because we're missing commit 0da7feaa5913 ("nvme-pci: use the tagset alloc/free helpers") we need to additionally remove the blk_put_queue from nvme_dev_remove_admin in pci.c to properly fix the UAF ] Signed-off-by: Maximilian Heyne Tested-by: Fedor Pchelkin --- drivers/nvme/host/core.c | 3 ++- drivers/nvme/host/pci.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 044e1a9c099b3..f17318f6c82b0 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -5043,7 +5043,6 @@ EXPORT_SYMBOL_GPL(nvme_alloc_admin_tag_set); void nvme_remove_admin_tag_set(struct nvme_ctrl *ctrl) { blk_mq_destroy_queue(ctrl->admin_q); - blk_put_queue(ctrl->admin_q); if (ctrl->ops->flags & NVME_F_FABRICS) { blk_mq_destroy_queue(ctrl->fabrics_q); blk_put_queue(ctrl->fabrics_q); @@ -5186,6 +5185,8 @@ static void nvme_free_ctrl(struct device *dev) container_of(dev, struct nvme_ctrl, ctrl_device); struct nvme_subsystem *subsys =3D ctrl->subsys; =20 + if (ctrl->admin_q) + blk_put_queue(ctrl->admin_q); if (!subsys || ctrl->instance !=3D subsys->instance) ida_free(&nvme_instance_ida, ctrl->instance); =20 diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 38732c0c28bbb..e8b7b0004086c 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1782,7 +1782,6 @@ static void nvme_dev_remove_admin(struct nvme_dev *de= v) */ nvme_start_admin_queue(&dev->ctrl); blk_mq_destroy_queue(dev->ctrl.admin_q); - blk_put_queue(dev->ctrl.admin_q); blk_mq_free_tag_set(&dev->admin_tagset); } } --=20 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 From nobody Fri Apr 3 16:05:01 2026 Received: from iad-out-010.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-010.esa.us-east-1.outbound.mail-perimeter.amazon.com [34.197.254.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E79E3ED101; Thu, 2 Apr 2026 13:57:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=34.197.254.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138248; cv=none; b=cTzT8eZnj3FwXfFw3U5Dsbqdt+u94n8I6vpDJiritjZqGjtVJBJVq/uxTipHay1F/0SDROMqaXpk22CJhcpHmajxbuc2aPMj7BPVmlCmijQCgN/Quwj1D84GE3F/jTUyHnL2v60IsWaTMdHsfp+yz8tcXga3KUjtWqLZ9pIikYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775138248; c=relaxed/simple; bh=DwjYrCrYHiZGVHlaDfF21bfSKi2+EKC0p0kSlXD7b74=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=Ob9nmjvBxkPG+MQByBvB3qwAITHKPkl/r+XVewKUzX7wg2WX/kb5ui93QFv/+umQ5UIVw9oeDF9lHXOtklHm605PFS/8DImvdW+0qBxz/tqLF/ILqXHIZJUZRmfDTV6Maiga+NSFz9Gbl2gkL3bHgnWWtSFubYsIYBRVzwGmybc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=JLvRPH9x; arc=none smtp.client-ip=34.197.254.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="JLvRPH9x" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775138246; x=1806674246; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=mvU/lZdi2hYsgWu6W9JVHisJHcxM5S1ZidU29vypwvM=; b=JLvRPH9xw7nJLHk2Hiv7M7T0Fqh10BBM0lPcuA2xoTIyQ5M6mGheQTer 1T5sZj+vtC19NAfUKkTf8NAglDUxDpwwhQcrl1QkUD/g1vMd2HfuYDyvQ 2hoEk1cg/mXxyZL/MWFMeFS1qF2TG2c0Ltkwgs4Ukt8r8oRVMPuqIcUKn XQd/wESdpQBARCptGZvYb1ql2IT5wDeEK7an7AjBsA5eB/JcFIu4VIl7Q Sl524cyWbKItkTekkiR54fRgXMemWkO7Chz3G/Za7if1ONjmHivOEx+i8 Nugv1QDwXVaS7I44sbxxW3T9RpquxTxf2egiMKg0KXky5NpXb6weLqutF Q==; X-CSE-ConnectionGUID: auy+wLkAQYWw59kc47d3Bw== X-CSE-MsgGUID: Kb+i6j18TzmrWueDucDIBA== X-IronPort-AV: E=Sophos;i="6.23,155,1770595200"; d="scan'208";a="15101635" Received: from ip-10-4-22-235.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.22.235]) by internal-iad-out-010.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2026 13:57:22 +0000 Received: from EX19MTAUEC001.ant.amazon.com [52.94.133.142:22247] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.39.103:2525] with esmtp (Farcaster) id d07190eb-e20f-4e37-9699-b4099791098d; Thu, 2 Apr 2026 13:57:22 +0000 (UTC) X-Farcaster-Flow-ID: d07190eb-e20f-4e37-9699-b4099791098d Received: from EX19D012UEC003.ant.amazon.com (10.252.135.160) by EX19MTAUEC001.ant.amazon.com (10.252.135.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:21 +0000 Received: from EX19D012UEC003.ant.amazon.com (10.252.135.160) by EX19D012UEC003.ant.amazon.com (10.252.135.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Thu, 2 Apr 2026 13:57:21 +0000 Received: from EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9]) by EX19D012UEC003.ant.amazon.com ([fe80::67ea:859:1e17:25a9%3]) with mapi id 15.02.2562.037; Thu, 2 Apr 2026 13:57:21 +0000 From: "Heyne, Maximilian" To: "stable@vger.kernel.org" CC: "Heyne, Maximilian" , Ming Lei , Keith Busch , Yi Zhang , Jens Axboe , Hector Martin , Sven Peter , Alyssa Rosenzweig , "Christoph Hellwig" , Sagi Grimberg , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , "Avri Altman" , Bart Van Assche , "Sasha Levin" , Peter Wang , "Greg Kroah-Hartman" , Seunghwan Baek , Seunghui Lee , "Adrian Hunter" , Brian Kao , "Sanjeev Yadav" , Wonkon Kim , Chaitanya Kulkarni , Hannes Reinecke , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "asahi@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-nvme@lists.infradead.org" , "linux-scsi@vger.kernel.org" Subject: [PATCH 6.1.y v2 6/6] nvme: fix admin queue leak on controller reset Thread-Topic: [PATCH 6.1.y v2 6/6] nvme: fix admin queue leak on controller reset Thread-Index: AQHcwqigUhccylBZtkqEyTZV34R51w== Date: Thu, 2 Apr 2026 13:57:21 +0000 Message-ID: <20260402-fox-attic-82ebf113@mheyne-amazon> References: <20260402-moral-jockey-f072379b@mheyne-amazon> In-Reply-To: <20260402-moral-jockey-f072379b@mheyne-amazon> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ming Lei [ 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 Fixes: 03b3bcd319b3 ("nvme: fix admin request_queue lifetime"). Reported-and-tested-by: Yi Zhang Closes: https://lore.kernel.org/linux-block/CAHj4cs9wv3SdPo+N01Fw2SHBYDs9tj= 2M_e1-GdQOkRy=3DDsBB1w@mail.gmail.com/ Signed-off-by: Ming Lei Signed-off-by: Keith Busch [ 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 Tested-by: Fedor Pchelkin --- 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; =20 + /* + * 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 =3D blk_mq_init_queue(set); if (IS_ERR(ctrl->admin_q)) { ret =3D 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 =3D set; =20 + /* + * 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 =3D blk_mq_init_queue(set); if (IS_ERR(dev->ctrl.admin_q)) { blk_mq_free_tag_set(set); --=20 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