[PATCH] scsi: scsi_debug: Drain target cleanup before module exit

From: Giuseppe Piscitelli

Date: Mon Oct 26 2026 - 16:29:22 EST


Target destruction queues cleanup in an exclusive async domain. The
module loader's async_synchronize_full() does not wait for exclusive
domains. Wait for target cleanup after removing the hosts and before
removing the debugfs root and returning from module exit.

Fixes: b402a0dce64a ("scsi: scsi_debug: Fix create target debugfs failure")
Signed-off-by: Giuseppe Piscitelli <ooonea@xxxxxxxxx>
---
OpenAI Codex found this gap during SCSI teardown analysis and wrote the
fix and its local validation.

Earlier validation included a Linux 7.3 build and three ordinary
corrected-module lifecycles. No unpatched race was forced; this gap was
not established as the cause of the original allocation messages. This
base was checked for applicability; no new build or runtime test was run.

drivers/scsi/scsi_debug.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 3346562..8aa8652 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -8675,6 +8675,7 @@ static void __exit scsi_debug_exit(void)

sdebug_erase_all_stores(false);
xa_destroy(per_store_ap);
+ async_synchronize_full_domain(&sdebug_async_domain);
debugfs_remove(sdebug_debugfs_root);
}

base-commit: 6a53f401e671b75c129245e371ca6e9d47fc3c9a
--
2.54.0