[PATCH] scsi: fc: Fix potential workqueue leak on rport creation failure
From: Guangshuo Li
Date: Mon Nov 09 2026 - 08:10:24 EST
The remote-port devloss workqueue is allocated before device_add().
If registration fails, the error path frees the rport without destroying
the queue. Destroy it before releasing the rport.
This issue was found by our static analysis tool under development.
Fixes: 25236d4844ad ("scsi: scsi_transport_fc: Change to use per-rport devloss_work_q")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/scsi/scsi_transport_fc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index bec6ca38375b..f7d0947bf312 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -3180,6 +3180,7 @@ fc_remote_port_create(struct Scsi_Host *shost, int channel,
return rport;
delete_rport:
+ destroy_workqueue(rport->devloss_work_q);
transport_destroy_device(dev);
spin_lock_irqsave(&shost->host_lock, flags);
list_del(&rport->peers);
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4