Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: myrb: unregister the SCSI host on remove
@ 2026-11-04  2:14 Wentao Liang
  2026-11-04  2:23 ` sashiko-bot
  2026-11-04  7:54 ` Hannes Reinecke
  0 siblings, 2 replies; 5+ messages in thread
From: Wentao Liang @ 2026-11-04  2:14 UTC (permalink / raw)
  To: Hannes Reinecke, James E.J. Bottomley, Martin K. Petersen; +Cc: linux-scsi

scsi_add_host() takes a reference on the host device that is only
dropped by scsi_remove_host() when the host and its children are
unregistered.  myrb_remove() goes straight to myrb_cleanup(), which only
drops the reference taken by scsi_host_alloc(), so the host stays
registered after the PCI device is removed and the memory behind it is
leaked.

Call scsi_remove_host() before tearing the controller down so that no
new commands are queued and the host is unregistered.

Fixes: 081ff398c56c ("scsi: myrb: Add Mylex RAID controller (block interface)")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/scsi/myrb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index 95df6e5345f7..e43d86f139c1 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -3496,6 +3496,7 @@ static void myrb_remove(struct pci_dev *pdev)
 {
 	struct myrb_hba *cb = pci_get_drvdata(pdev);
 
+	scsi_remove_host(cb->host);
 	shost_printk(KERN_NOTICE, cb->host, "Flushing Cache...");
 	myrb_exec_type3(cb, MYRB_CMD_FLUSH, 0);
 	myrb_cleanup(cb);
-- 
2.34.1


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

end of thread, other threads:[~2026-11-05  5:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:14 [PATCH] scsi: myrb: unregister the SCSI host on remove Wentao Liang
2026-11-04  2:23 ` sashiko-bot
2026-11-04  7:54 ` Hannes Reinecke
2026-11-04  8:33   ` Krzysztof Kozlowski
2026-11-05  5:51     ` Wentao Liang

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