From nobody Wed Apr 1 20:46:27 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 6F52D406267; Wed, 1 Apr 2026 13:37:03 +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=1775050625; cv=none; b=eSnJpOYECBOn/wA5BZpXoA9YRqgMR9ouCgMlAXE+A0U4jWt7UfIKj+1A81bAcyzHb/g5da7MCq2FVlPtEMcm4i36r7cMsamGPVCkERRyydjfASKZGb6aZrBB9H9RMLxCaqHBj3QU9+nWABNHNUPt2lV9ebTtl8X80OvJQ2ATs9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050625; c=relaxed/simple; bh=s7wRlY/NElhgO0hzbPLkyqy9K97X1PSdyfsNpCekHmA=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=c1N0nO6X8YbdSa6TNLgj7LBXIyD9X78b+++dtovCxZuF82vp74zmfwoBFtO20A3x5ZVB8tSdwpGSeaQTLVVLOP2kiow01wbT3dIrh3S9+LoCQu0c8F8vv9ZTlLb/4PJlUWKup1ObbEVZmy51+/2mFOIKOlxKVQ6QrzkTJP1IA+w= 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=UwOoGhxo; 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="UwOoGhxo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775050623; x=1806586623; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=dLVMAKqyGscpMd3RaTb0PTlAAEY6ecJ8SdxwSVZ0340=; b=UwOoGhxoN7AbWURibQ/GmjoUnaLAcnFwybsBv6ULh7M59qtwLw5KKxgK Mb0b64EFMV6cjd9xn5Un3xdqYqmymh5oB4j3+/cUmB1EeJnw71z+C6atk kEKAJEfPXD3tH2IfH7PapNfKvzNR07OgKdF+lkqBZ3nDC22g6qM3X9/Re qjjFYBlZnB2FF40tv6hazsGTdpnduvFlJiepFgsi/qN/ZZbfM0w4jhnsu oZuoRiSpeFC60lbO4Zh+dpeVaiHpbevF3N2t6SxcnHSClPyUPNIMcpajR B0IW5BQG6/edkugg/mOFbESSLosLwIanq70sBzCX54Up7sr62lNfAYQ1G A==; X-CSE-ConnectionGUID: nkfwnKAOR2a89Vp4yTuwNw== X-CSE-MsgGUID: NKaMDt+ATpqEH+/8F8yegA== X-IronPort-AV: E=Sophos;i="6.23,153,1770595200"; d="scan'208";a="14739828" Received: from ip-10-4-13-79.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.13.79]) by internal-iad-out-014.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 13:36:59 +0000 Received: from EX19MTAUEC001.ant.amazon.com [52.94.133.134:10610] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.95.220:2525] with esmtp (Farcaster) id 442ca74e-e7fa-4a65-a99e-8452b83b2313; Wed, 1 Apr 2026 13:36:59 +0000 (UTC) X-Farcaster-Flow-ID: 442ca74e-e7fa-4a65-a99e-8452b83b2313 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; Wed, 1 Apr 2026 13:36:57 +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; Wed, 1 Apr 2026 13:36:56 +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; Wed, 1 Apr 2026 13:36:56 +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" , Wonkon Kim , Seunghwan Baek , "Adrian Hunter" , Bean Huo , 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 1/8] Revert "nvme: fix admin request_queue lifetime" Thread-Topic: [PATCH 6.1.y 1/8] Revert "nvme: fix admin request_queue lifetime" Thread-Index: AQHcwdybH4188GigBECVKFyE1IXyog== Date: Wed, 1 Apr 2026 13:36:56 +0000 Message-ID: <20260401-figure-weird-3a1932c2@mheyne-amazon> References: <20260401-defer-gleam-5226cb65@mheyne-amazon> In-Reply-To: <20260401-defer-gleam-5226cb65@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 --- 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 Wed Apr 1 20:46:27 2026 Received: from iad-out-007.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-007.esa.us-east-1.outbound.mail-perimeter.amazon.com [3.221.209.22]) (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 B66B82BEC2C; Wed, 1 Apr 2026 13:37:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.221.209.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050623; cv=none; b=cu/9CKUFXSusqtPjiD5syCFSYlji2UpOr/dvDaaDMA8epl0WflKHJaG7SyrSyCSeVtwH2Jmhyy+vqjzGm/s9zlIt4KGZmgfAco12p95KPjDIoRyqQsRKg+aomUwuRdL7Ub/OKkhePs4FsMMfCxEQE2mut3dPU4umkczWg8YWokM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050623; c=relaxed/simple; bh=vpq4nB3qwZzEF+4p6P592kZd1o2sPQZYwp9+15SRk2E=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=cYN7bg9HxIkAfdXS8pBOgTXBAv4flUqqnLM0UD0zzRvkDLUB4rUsdMJ1aZVkSPoYIOZLixn5HVlse/KMIHDsY1HgGejIyX6YH3KMB+Rmti7iIjb8uHTy1Jn9UwfmilKSWj6Av1saDZEDaS1wDyJZdS1edf1SumeS5odzzhHx6z0= 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=WoIx5u0M; arc=none smtp.client-ip=3.221.209.22 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="WoIx5u0M" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775050622; x=1806586622; 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=WoIx5u0MMcRat5wNpt0cYGpc/6Us63IUXWkbY+DCCowlnOm8D03I3qkJ dAwMw/ooZGrgj6zfBuLOzmfEuJPQQHlOt3sJzZ+TGHgElzp3qCcjboIqK InWsrt/0ToWnMQuZqIGqIqo6wJ59drw1yOchjUVU2+KYRjsD6PeL0fl18 6DiPhCwMUGx/rzFUaGmBgdIXX6ZpcSyBQq7OL9oOyWzRK3eyDAH02sTow tRkSj4m8jFg7uQcO0Iyn58tbYj2XsaOO/Kjvnzhu0DIxMRyIhTD8/PoOt GA/ZH5fnmnsJrBKmXO+CFS5pEryMJGDVBKzwP7FIBFdzfSD6yjfuZ0xtr Q==; X-CSE-ConnectionGUID: qkzQSM3KQLWzasintYDu2w== X-CSE-MsgGUID: 75F1YqcgT1yDcLfS194f3A== X-IronPort-AV: E=Sophos;i="6.23,153,1770595200"; d="scan'208";a="15299613" Received: from ip-10-4-10-75.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.10.75]) by internal-iad-out-007.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 13:36:59 +0000 Received: from EX19MTAUEA001.ant.amazon.com [72.21.196.67:18181] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.17.255:2525] with esmtp (Farcaster) id 5a89eca9-fb6b-4296-84c0-9f378bbb3c74; Wed, 1 Apr 2026 13:36:59 +0000 (UTC) X-Farcaster-Flow-ID: 5a89eca9-fb6b-4296-84c0-9f378bbb3c74 Received: from EX19D012UEC001.ant.amazon.com (10.252.135.206) by EX19MTAUEA001.ant.amazon.com (10.252.134.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Wed, 1 Apr 2026 13:36:59 +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; Wed, 1 Apr 2026 13:36:58 +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; Wed, 1 Apr 2026 13:36:58 +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 , Seunghwan Baek , Bean Huo , Thomas Yen , Brian Kao , "Seunghui Lee" , Sanjeev Yadav , "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 2/8] blk-mq: move the call to blk_put_queue out of blk_mq_destroy_queue Thread-Topic: [PATCH 6.1.y 2/8] blk-mq: move the call to blk_put_queue out of blk_mq_destroy_queue Thread-Index: AQHcwdycwz+7VPd2vkmdKVAi3XDU9Q== Date: Wed, 1 Apr 2026 13:36:58 +0000 Message-ID: <20260401-plank-yogi-fbc6b91f@mheyne-amazon> References: <20260401-defer-gleam-5226cb65@mheyne-amazon> In-Reply-To: <20260401-defer-gleam-5226cb65@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 --- 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 Wed Apr 1 20:46:27 2026 Received: from iad-out-008.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-008.esa.us-east-1.outbound.mail-perimeter.amazon.com [34.193.58.168]) (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 4292E43C06C; Wed, 1 Apr 2026 13:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=34.193.58.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050627; cv=none; b=oRgyzSKcTq1cgwfGgAsL2DBS7RGLCmKeDQkhFLnOYbrNPgYdad6ujtHaZzTT9nRmoiBvpV1FgJpCKHTUxJQdVnQpxwyruEhRnPcCY4Hf5P13MWKL2TSyuOmSggvKbWN2ZGufrWZvbK7IAg6sv69aOKuxbnUIJVbj/svNfysfHJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050627; c=relaxed/simple; bh=ViYXT97lI2Z0arqoS4YYAI4QycWhfakOGGvWTVpUDL0=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=a7AT9xGBLhadfGYu7XibvD9PZG5HXvfw6NJLWmBj3ucCJO5eMkF/lu6VzSFsJtxiNfgm3T+oQznrqIRfIzBkDe7Z0Zr3x5nQQt99RFhJprVQIF3sZQoYaHr/6N7olm6Do9Yj3GV+sLlJPjjEwUDN0ZMDnUrb3TTnGFMmoMyhoR0= 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=AwBT2nuK; arc=none smtp.client-ip=34.193.58.168 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="AwBT2nuK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775050625; x=1806586625; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=cpgdsRBIfybYQpKIU9QXK+ymTOvzqCHCto1T2WRCbVo=; b=AwBT2nuKJopfX2cbPO4IGg7AwalXdl87PPonf4Hv2Vi29jgq51nkW+iQ LSa1z/5cql4Ci1/EGwp2AYtx9UaPNhJ4hjjMR7JB/5uK4R/baMGIZa4Zq OA2KrFawQzglQ36IYF2Me5RjY8/DhutZ7N8ysrdkxc2w5TmDTcBJKRxsa n283jNP678KwOy7GN4R4wWvctmItcqSZydS8eOzZ2b+hOWIZD+6nQU939 LdvPCORZcqXM53I13qjikMw6VrZTQzFRNmB0aWoko5Cnd5WKaL0ikDhXt h148cmOkvHDvIfC0xw0QI7HSEsA/4gUCn+MW5n7o+kwZ6jE+tjn1AADP+ Q==; X-CSE-ConnectionGUID: 34e5EzuFRgOV31aCHGvb+A== X-CSE-MsgGUID: efuqIHR3QoqOjf3QTAMGtw== X-IronPort-AV: E=Sophos;i="6.23,153,1770595200"; d="scan'208";a="15127073" Received: from ip-10-4-10-75.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.10.75]) by internal-iad-out-008.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 13:37:01 +0000 Received: from EX19MTAUEC002.ant.amazon.com [72.21.196.66:16921] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.95.220:2525] with esmtp (Farcaster) id b4971fc6-7db9-411c-927e-3ab4757a8014; Wed, 1 Apr 2026 13:37:01 +0000 (UTC) X-Farcaster-Flow-ID: b4971fc6-7db9-411c-927e-3ab4757a8014 Received: from EX19D012UEC002.ant.amazon.com (10.252.135.254) 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; Wed, 1 Apr 2026 13:37:00 +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; Wed, 1 Apr 2026 13:37:00 +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; Wed, 1 Apr 2026 13:37:00 +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 , Bean Huo , 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 3/8] scsi: remove an extra queue reference Thread-Topic: [PATCH 6.1.y 3/8] scsi: remove an extra queue reference Thread-Index: AQHcwdydSAl8T/8/v0W8CfQbTcumKA== Date: Wed, 1 Apr 2026 13:37:00 +0000 Message-ID: <20260401-blobs-hurry-1dd1b23c@mheyne-amazon> References: <20260401-defer-gleam-5226cb65@mheyne-amazon> In-Reply-To: <20260401-defer-gleam-5226cb65@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 dc917c361422388f0d39d3f0dc2bc5a188c01156 ] Now that blk_mq_destroy_queue does not release the queue reference, there is no need for a second queue reference to be held by the scsi_device. 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-3-hch@lst.de Signed-off-by: Jens Axboe Signed-off-by: Maximilian Heyne --- drivers/scsi/scsi_scan.c | 1 - drivers/scsi/scsi_sysfs.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 696f178fb57d8..0eaec372f7560 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -344,7 +344,6 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_= target *starget, sdev->request_queue =3D q; q->queuedata =3D sdev; __scsi_init_queue(sdev->host, q); - WARN_ON_ONCE(!blk_get_queue(q)); =20 depth =3D sdev->host->cmd_per_lun ?: 1; =20 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index af81b2ba0c9b3..456b92c3a7811 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -1486,7 +1486,6 @@ 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 --=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 Wed Apr 1 20:46:27 2026 Received: from iad-out-013.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-013.esa.us-east-1.outbound.mail-perimeter.amazon.com [34.198.218.121]) (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 8E53743E485; Wed, 1 Apr 2026 13:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=34.198.218.121 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050632; cv=none; b=mtjf625H5NOPck6eoFyoOcrCbo+nU8Mw3oriPinp28rp3Gvl8zFq0PlJuIJuTNH0o3y3kV2YrVFeq4EE8sc0MOUoQcTHtgzlLG8ekHzxHfc02JJpBTK5xMTM4IMijGUToy9TZszYkNFfEVFo/n6Ku/kNQYWCL9l9qeC4lErp7jw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050632; c=relaxed/simple; bh=1+WHPwcQvkrDqjN7jtha7n2OLLRrBtkNbbXM9KBS+Vk=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=jlsxQkzVQZMVwEky2vrTLODbOWWIEqqIur4ZldrMukXxonRK/KLgt0zzE1pSmg9Bxh+3kFs7w664+JANH19y/dvGNzk0L7n8r7i7vGN/aXn49MPHO+wPiPJOwYJEWCVKOh67zVU+uFDAMe6+vnepHGREgtYNK+g8a0Z0eplzY+I= 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=dBGzWfrw; arc=none smtp.client-ip=34.198.218.121 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="dBGzWfrw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775050630; x=1806586630; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=wuthZuZJNuIVCbef4TvR92fybPm79mBQ8LikDhPWnf0=; b=dBGzWfrw75o1NSXK8TCJCzSSMfCvFtcw+hN1Jmh/QV1LLEXTXnobJISo vRMlw5dyuDCeDKvDj8C8URCZ4p/QpD8J/MyxyZcqAH4ZkUSCSbLPaEn9G NKrsJZQnFXia7lqHBB1zzDtmzvKf/d6M1oIc1bPk3M3Otoj8WylPE0Msu zeatqB3l4IcxrksXNbpDZR+WE6nxPAxSygG8zB/ueZLtEfnYxq+TMUKr2 0k4BipKyTxPMVyUuNrcCy5ORLqD3+6f/PQMF6ejwnrvQywrhXgyYlRyNC K3b7+/AI77JtzW1oD3j6EZP6i6VZgdodJciBfDydHh9bNqaBPEqCwpeZj g==; X-CSE-ConnectionGUID: Y52wK3WyQnCQaxue3N9eZw== X-CSE-MsgGUID: BvBLo81GSHqURNQ2EZY2FQ== X-IronPort-AV: E=Sophos;i="6.23,153,1770595200"; d="scan'208";a="14740612" Received: from ip-10-4-7-229.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.7.229]) by internal-iad-out-013.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 13:37:04 +0000 Received: from EX19MTAUEB002.ant.amazon.com [72.21.198.67:21684] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.8.197:2525] with esmtp (Farcaster) id b3ce9a85-508e-4dd2-9849-9f140f408e54; Wed, 1 Apr 2026 13:37:03 +0000 (UTC) X-Farcaster-Flow-ID: b3ce9a85-508e-4dd2-9849-9f140f408e54 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; Wed, 1 Apr 2026 13:37:02 +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; Wed, 1 Apr 2026 13:37:01 +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; Wed, 1 Apr 2026 13:37:01 +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 , Bean Huo , Brian Kao , Wonkon Kim , Seunghui Lee , Sanjeev Yadav , 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 4/8] nvme-pci: remove an extra queue reference Thread-Topic: [PATCH 6.1.y 4/8] nvme-pci: remove an extra queue reference Thread-Index: AQHcwdyeS0oU7vvtXEuRvFkEk0UbGA== Date: Wed, 1 Apr 2026 13:37:01 +0000 Message-ID: <20260401-oat-connect-4976b717@mheyne-amazon> References: <20260401-defer-gleam-5226cb65@mheyne-amazon> In-Reply-To: <20260401-defer-gleam-5226cb65@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 --- 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 Wed Apr 1 20:46:27 2026 Received: from iad-out-005.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-005.esa.us-east-1.outbound.mail-perimeter.amazon.com [3.211.80.218]) (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 5FE8443DA23; Wed, 1 Apr 2026 13:37:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.211.80.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050630; cv=none; b=U0sTyK4zWuBKnKpAMdCGXPXCE+T3R9xopQoHwkIl0DVLqDGILYxFG/5q58YIqKK3Gpafz/6AtpOvncM1eDFquXxQRvnWld8ACd93BYJzVoHbTyzKHzHOgemib5efESHlmNAumjDeEwadMXfAKTElVPUJ4UPhnssOc+w0FIDu6hg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050630; c=relaxed/simple; bh=3xvN3w6SnmA8quBEkyn+GZeH+zMeWFsT8ga3lGlXgPA=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=eHU8dkx6J73bk9JTmNIjTK5M6xqs9SKqEMZpXrHPwUDOUZgZZtLIjLeb97Ik4cirgMo5sIaOUsHPnZbJQ9lvN0Gpg6Yg8XmPZ0iP9OW6HQI9JKubzxE8U4qS9CAhwRmVx+wNL8tbZSuDRQV6+CTQy3gEISP7fNzToR9Dj2xnxkM= 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=W6/JtSJI; arc=none smtp.client-ip=3.211.80.218 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="W6/JtSJI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775050628; x=1806586628; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=OF/Wc7TK+OsFr31ZdtePyiprlbzI65l7D2fgL0og7g8=; b=W6/JtSJIeILxxa3ITEpRSZKz4+G7G5QYn6Zs3K8srh35b/IqMMUMQLTq HweLWtq1iFgE8CotPe1hUR58046dD5EEX7pUJJdlLgYG0CQeCV07Y5kq5 Ub0Kp1o3eajnO7bFf5sLJ8Qh8Juub9kuUk+b9rt7fJogFlSjaWp3qp0C2 0gXRtYMgrlNjFeVmg1mfSRIaVR1EuPjrAni5gNg/wLsfcHSuAW2z0xDom n7dniiTmxb4QI9iNqTlufGjyRnjSJepvLcZhFewBlVHUFIw9+Rq3fCXl8 tm3iV2DrW+hTsEt22u7pHlNT0d6NR55hpzFkzunQA1sSM79tprwKwI47s g==; X-CSE-ConnectionGUID: UMssy2gNTFW+S4U/A5mK4A== X-CSE-MsgGUID: j2rWxdH+QcqQjtHpTDJFrQ== X-IronPort-AV: E=Sophos;i="6.23,153,1770595200"; d="scan'208";a="15275470" Received: from ip-10-4-7-229.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.7.229]) by internal-iad-out-005.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 13:37:04 +0000 Received: from EX19MTAUEC002.ant.amazon.com [72.21.198.66:5147] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.8.197:2525] with esmtp (Farcaster) id 5da5a075-cb06-4684-aedc-ecbaf014acc0; Wed, 1 Apr 2026 13:37:04 +0000 (UTC) X-Farcaster-Flow-ID: 5da5a075-cb06-4684-aedc-ecbaf014acc0 Received: from EX19D012UEC001.ant.amazon.com (10.252.135.206) 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; Wed, 1 Apr 2026 13:37:03 +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; Wed, 1 Apr 2026 13:37:03 +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; Wed, 1 Apr 2026 13:37:03 +0000 From: "Heyne, Maximilian" To: "stable@vger.kernel.org" CC: "Heyne, Maximilian" , Christoph Hellwig , Sagi Grimberg , Sven Peter , "Chaitanya Kulkarni" , Keith Busch , Jens Axboe , Hector Martin , Alyssa Rosenzweig , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , Avri Altman , Bart Van Assche , Sasha Levin , Peter Wang , Greg Kroah-Hartman , Seunghui Lee , Sanjeev Yadav , Wonkon Kim , Brian Kao , "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 5/8] nvme-apple: remove an extra queue reference Thread-Topic: [PATCH 6.1.y 5/8] nvme-apple: remove an extra queue reference Thread-Index: AQHcwdyfxKwQXg5Z9kGUiGR8yB37yw== Date: Wed, 1 Apr 2026 13:37:03 +0000 Message-ID: <20260401-pliny-ashley-ff03a0b6@mheyne-amazon> References: <20260401-defer-gleam-5226cb65@mheyne-amazon> In-Reply-To: <20260401-defer-gleam-5226cb65@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 941f7298c70c7668416e7845fa76eb72c07d966b ] 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 apple_nvme structure. Signed-off-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Reviewed-by: Sven Peter Reviewed-by: Chaitanya Kulkarni Reviewed-by: Keith Busch Link: https://lore.kernel.org/r/20221018135720.670094-5-hch@lst.de Signed-off-by: Jens Axboe Signed-off-by: Maximilian Heyne --- drivers/nvme/host/apple.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c index c5fc293c22123..c84ebfcfdeb88 100644 --- a/drivers/nvme/host/apple.c +++ b/drivers/nvme/host/apple.c @@ -1507,15 +1507,6 @@ static int apple_nvme_probe(struct platform_device *= pdev) goto put_dev; } =20 - 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; - } - nvme_reset_ctrl(&anv->ctrl); async_schedule(apple_nvme_async_probe, anv); =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 Wed Apr 1 20:46:27 2026 Received: from iad-out-013.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-013.esa.us-east-1.outbound.mail-perimeter.amazon.com [34.198.218.121]) (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 37DD143D51A; Wed, 1 Apr 2026 13:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=34.198.218.121 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050630; cv=none; b=Ad7Bi8yW/RVrhojbPlm7FpqVXmxZwBwLR5v7FCaNg7hEBx4O7pSqym78Mk66Re+4TpZcxRORNZULlHgNAXJDPE/gjObOsp9Bav3RN91gyO9R43/N7ar2CqFcoGuCe+xHSJuh4sDLedaTkbkF7oy8ZWFmSDSajzj3K1cOeEpzL3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050630; c=relaxed/simple; bh=Qrk8GSV96kDDkq1+0VAMC53OBa1WpEWTZeLl1slKnmA=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=YLTE0vgdMQSaT3vgk3fSx4VMIZtYUrS6S09lvg8odYkwcGBnb+ccHrfLODlpXQipeVkHOfZNFxUP3ETEGXvYHCKWBaejDtppIlOpMEPDloC1xD4u+pFqpb+fC9dxKWUGUz4ZMxS+LRRdV7UsC+JKNYGywnVMMAcy6nrVvnYefaE= 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=fO1SG79x; arc=none smtp.client-ip=34.198.218.121 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="fO1SG79x" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775050628; x=1806586628; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=yyrWPY5Ev1YqXQNI936Pi4tZz7GWIXsbdLr6GEho4RU=; b=fO1SG79xsimdv16UVio+/O0bam0BJ2lZ7dgbo2E+0488AXWrJPh5LcA0 LIyXRRXK/afCjJ4bK4BzD7kcRh53gaRKTWeTDsWGicoXzNm+WVeJCVmlb LG2O6uOJGAmFEuS0fa/BKZA1I7gIxfWxycownNFZaoZDIGaX2WydxDb7z hmGeDlqQeF8CUIUhM0x9BrgAHUz2rhulmuVnSGRqmuuAe9VgGq4J6d1Cy kdReBaWKUyRtBi29bItmCBgCbl/4HVAUYMlZNlYtrPWhNV52LFOoDyDGr zuqEkGJByZSS0C5UycsOgjg+qUXYvhZ8b6f0DRYdmfngpHChl/nDC+lsp A==; X-CSE-ConnectionGUID: 3S/LPCjRSD6mXfvS8BfF4Q== X-CSE-MsgGUID: U7tph4hZTj+7Zz7buNfCIQ== X-IronPort-AV: E=Sophos;i="6.23,153,1770595200"; d="scan'208";a="14740616" Received: from ip-10-4-13-79.ec2.internal (HELO smtpout.naws.us-east-1.prod.farcaster.email.amazon.dev) ([10.4.13.79]) by internal-iad-out-013.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 13:37:06 +0000 Received: from EX19MTAUEC001.ant.amazon.com [52.94.133.134:17575] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.17.255:2525] with esmtp (Farcaster) id d5b417ca-06c6-438e-9b58-67511adcf066; Wed, 1 Apr 2026 13:37:05 +0000 (UTC) X-Farcaster-Flow-ID: d5b417ca-06c6-438e-9b58-67511adcf066 Received: from EX19D012UEC002.ant.amazon.com (10.252.135.254) 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; Wed, 1 Apr 2026 13:37:05 +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; Wed, 1 Apr 2026 13:37:05 +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; Wed, 1 Apr 2026 13:37:05 +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 , Seunghui Lee , Brian Kao , Adrian Hunter , Sanjeev Yadav , 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 6/8] nvme-pci: put the admin queue in nvme_dev_remove_admin Thread-Topic: [PATCH 6.1.y 6/8] nvme-pci: put the admin queue in nvme_dev_remove_admin Thread-Index: AQHcwdygkRu0MfiJH0aFifOxHgnywA== Date: Wed, 1 Apr 2026 13:37:05 +0000 Message-ID: <20260401-fugue-granite-a4156254@mheyne-amazon> References: <20260401-defer-gleam-5226cb65@mheyne-amazon> In-Reply-To: <20260401-defer-gleam-5226cb65@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 --- 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 Wed Apr 1 20:46:27 2026 Received: from iad-out-007.esa.us-east-1.outbound.mail-perimeter.amazon.com (iad-out-007.esa.us-east-1.outbound.mail-perimeter.amazon.com [3.221.209.22]) (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 3BB4643D51D; Wed, 1 Apr 2026 13:37:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.221.209.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050630; cv=none; b=gWmaW0VXDBxtJ0EweMvd/F410c166d1CPL3lM/tp8At/ISOUDBTkHAQE+cmzCL8wFkFKkeKHlxgUCJf49EVdk14RxmRoG86mJKa5uIs4SBvNVOJtz5aK7tAnyO2LL8pEpH84mhw1+QNZuOCBQRQrEx6wXdO4oJhGwnUMVWYkoW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050630; c=relaxed/simple; bh=JG2Mv9KfI7xkq43R9tTrX6gyZeNUTJ68NxGSnZETtNU=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=hxMBBHD5MzlOLbqedSU6n9XihB7FJ2s0X2Lt7rX3NhrfFmvH6/GX50AmW6An2iMEC4kv3QSEEFaSuWQR4f2KROEuaggV08WxNB6Ysmh/l6KthqpmnIRGulq9Oxsi9d6sHO6xSRkmRXabGzvstDTkRqAbIlkrMrrKWwQ5gN+87PE= 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=ryyqZyeE; arc=none smtp.client-ip=3.221.209.22 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="ryyqZyeE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775050628; x=1806586628; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=uP5c6JzjwZwnGCsqflyTr1RQBZf98/zHqoDjD1LVIe8=; b=ryyqZyeEtxxfEjo+FnYPhxh1HTVzw58wq8j3sj9RrEFO1Y2GjpVmvogq JBHUw9wrd6LaTrGAFqi9p9f6pBaffl8tKoRpmHqO6zsgm9HMGgzWFeGYy 01Zry6zqUHHmeqe4yBLkKwk/gBJQGWkUNVHeWCquGd1MHwduzhdvVd7HO gA+o2isRNLVAoxs8tAU5+PtLAnyeTmbBedSJux/WjK8GLBsLU8kgCdEGi ZQ9a7FBSgquiYgjvFiTjX/FbDeN6SHul7UZXTF9rV44v778BPNhp376N9 31GyEuGSiukIpTTTKy6LGRpbKSO+hz0b3p+lvNCP02QDO4AjTzh025GcP g==; X-CSE-ConnectionGUID: zLawT+wTR4W8WnCI2LkUkQ== X-CSE-MsgGUID: GueIiePrRhahwivpK1isTg== X-IronPort-AV: E=Sophos;i="6.23,153,1770595200"; d="scan'208";a="15299642" 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-007.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 13:37:07 +0000 Received: from EX19MTAUEB001.ant.amazon.com [72.21.198.67:5444] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.17.255:2525] with esmtp (Farcaster) id 0f038195-b495-4681-bad2-e90935ddb4f6; Wed, 1 Apr 2026 13:37:07 +0000 (UTC) X-Farcaster-Flow-ID: 0f038195-b495-4681-bad2-e90935ddb4f6 Received: from EX19D012UEC004.ant.amazon.com (10.252.135.219) by EX19MTAUEB001.ant.amazon.com (10.252.135.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Wed, 1 Apr 2026 13:37:07 +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; Wed, 1 Apr 2026 13:37:07 +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; Wed, 1 Apr 2026 13:37:07 +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" , Wonkon Kim , Sanjeev Yadav , Brian Kao , Seunghui Lee , "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 7/8] nvme: fix admin request_queue lifetime Thread-Topic: [PATCH 6.1.y 7/8] nvme: fix admin request_queue lifetime Thread-Index: AQHcwdyhnryy0gEdpE2mdsVx0tSoPQ== Date: Wed, 1 Apr 2026 13:37:06 +0000 Message-ID: <20260401-clef-ken-54e30c4e@mheyne-amazon> References: <20260401-defer-gleam-5226cb65@mheyne-amazon> In-Reply-To: <20260401-defer-gleam-5226cb65@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 --- 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 Wed Apr 1 20:46:27 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 88BF943E9D5; Wed, 1 Apr 2026 13:37:12 +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=1775050634; cv=none; b=OP8+fI+Kn7Rldd010mQztoV+KnE9CO/XkTk04W4KGjINdzkfycikQxi7R2uMuFofwAJ/0WK/y+Gi+yIQziD9Mj7a/DVAsdP3olzjR03XQbBGeOutwVsgjMtt4aExA9j8h+3aG8eLPSaUEtTUb/veluua8i2UOJU+dc8dr4oherA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050634; c=relaxed/simple; bh=DwjYrCrYHiZGVHlaDfF21bfSKi2+EKC0p0kSlXD7b74=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=A/QQDLDUonfCDfng7S6QGrQ7gK7pYbQK3m4w6vR2sZ9p5Sa9jhl/e3HOGvMaRFW14tE7izaBo5Ti7GcpIn9DOmUDUM1OfBlzWAdxm1q6OnqBbQx+vhZNikUn+SeOsHjC7NdMuV6+DbIwPQX74YD4gZLlGAHBPKP9vMmYFzr/QgU= 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=Nn1fZVxd; 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="Nn1fZVxd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1775050632; x=1806586632; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=mvU/lZdi2hYsgWu6W9JVHisJHcxM5S1ZidU29vypwvM=; b=Nn1fZVxd0G8Sd20Zr+jke0BYKrBJsJANhXmvQuvV9WCtyTiJriAodUAo xeMQ/LMayWSemCgNvneWEEQ9tsFQOHTOZf+ZUXN1odk8iqdj1YWwrwxVw 0PKQkbgGmowOHCxeljhj0h95ECYRr+GY4zROk/aXCjvDdhIThO9Sht0pr oNror1xi9qbWU8eJKM26wK6TW4UKuINt/8dXSBzv/V59uB20/vlO+aqvZ 2YBiWhrGboR4VvJsoyOnqeP06+mOl22rm+kxTuWS90iHG6dHIpPtVcPUS RlT62tfY8RY8/Ahx/yeHza6y4VU0Qf2+YrOXK081I+OxGmO7qe/Kv5uei Q==; X-CSE-ConnectionGUID: yfdDpBFSR3GzxI8zBmj5yg== X-CSE-MsgGUID: 8EJ0aWTvTGCaKUpocoCCkA== X-IronPort-AV: E=Sophos;i="6.23,153,1770595200"; d="scan'208";a="15009820" 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-010.esa.us-east-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 13:37:09 +0000 Received: from EX19MTAUEB002.ant.amazon.com [72.21.198.67:10436] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.56.32:2525] with esmtp (Farcaster) id d89d7eaa-5429-439e-9de0-f92aa02d1cf4; Wed, 1 Apr 2026 13:37:09 +0000 (UTC) X-Farcaster-Flow-ID: d89d7eaa-5429-439e-9de0-f92aa02d1cf4 Received: from EX19D012UEC003.ant.amazon.com (10.252.135.160) 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; Wed, 1 Apr 2026 13:37:08 +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; Wed, 1 Apr 2026 13:37:08 +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; Wed, 1 Apr 2026 13:37:08 +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" , Seunghui Lee , Adrian Hunter , Bean Huo , 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 8/8] nvme: fix admin queue leak on controller reset Thread-Topic: [PATCH 6.1.y 8/8] nvme: fix admin queue leak on controller reset Thread-Index: AQHcwdyiGHZGxTNpyEix/f1qqxhIpQ== Date: Wed, 1 Apr 2026 13:37:08 +0000 Message-ID: <20260401-bayou-lager-0ca6402b@mheyne-amazon> References: <20260401-defer-gleam-5226cb65@mheyne-amazon> In-Reply-To: <20260401-defer-gleam-5226cb65@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 --- 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