Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: fix refcount leaking for "tagset_refcnt"
@ 2026-02-23 23:27 Junxiao Bi
  2026-02-27 18:32 ` Mike Christie
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Junxiao Bi @ 2026-02-23 23:27 UTC (permalink / raw)
  To: linux-scsi; +Cc: martin.petersen, James.Bottomley, junxiao.bi

This leaking will cause hung when tearing down the scsi host.
This is an example with iscsi, iscsid hung with the following
call trace after this kernel log.

[130120.652718] scsi_alloc_sdev: Allocation failure during SCSI scanning, some SCSI devices might not be configured

PID: 2528     TASK: ffff9d0408974e00  CPU: 3    COMMAND: "iscsid"
 #0 [ffffb5b9c134b9e0] __schedule at ffffffff860657d4
 #1 [ffffb5b9c134ba28] schedule at ffffffff86065c6f
 #2 [ffffb5b9c134ba40] schedule_timeout at ffffffff86069fb0
 #3 [ffffb5b9c134bab0] __wait_for_common at ffffffff8606674f
 #4 [ffffb5b9c134bb10] scsi_remove_host at ffffffff85bfe84b
 #5 [ffffb5b9c134bb30] iscsi_sw_tcp_session_destroy at ffffffffc03031c4 [iscsi_tcp]
 #6 [ffffb5b9c134bb48] iscsi_if_recv_msg at ffffffffc0292692 [scsi_transport_iscsi]
 #7 [ffffb5b9c134bb98] iscsi_if_rx at ffffffffc02929c2 [scsi_transport_iscsi]
 #8 [ffffb5b9c134bbf0] netlink_unicast at ffffffff85e551d6
 #9 [ffffb5b9c134bc38] netlink_sendmsg at ffffffff85e554ef

Fixes: 8fe4ce5836e9 ("scsi: core: Fix a use-after-free")
Cc: stable@vger.kernel.org
Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
---
 drivers/scsi/scsi_scan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 7acbfcfc2172..c64ef71633d8 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -361,6 +361,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
 	 * since we use this queue depth most of times.
 	 */
 	if (scsi_realloc_sdev_budget_map(sdev, depth)) {
+		kref_put(&sdev->host->tagset_refcnt, scsi_mq_free_tags);
 		put_device(&starget->dev);
 		kfree(sdev);
 		goto out;
-- 
2.50.1 (Apple Git-155)


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

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

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 23:27 [PATCH] scsi: fix refcount leaking for "tagset_refcnt" Junxiao Bi
2026-02-27 18:32 ` Mike Christie
2026-02-27 18:46 ` Bart Van Assche
2026-02-28 22:28 ` Martin K. Petersen
2026-03-01  2:11 ` Martin K. Petersen
2026-03-02 10:30 ` John Garry
2026-03-02 20:36   ` junxiao.bi
2026-03-03 11:06     ` John Garry
2026-03-03 16:58       ` junxiao.bi

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