Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: mvsas: put the Scsi_Host when host setup fails
@ 2026-11-04  2:14 Wentao Liang
  2026-11-04  2:27 ` sashiko-bot
  2026-11-04  7:12 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-04  2:14 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen; +Cc: linux-scsi

mvs_pci_init() allocates the Scsi_Host with scsi_host_alloc() and, once
everything has been set up, hands it to mvs_pci_remove(), which ends up
dropping the allocation reference through mvs_free().

Probing can fail after the host has been added: scsi_add_host(),
sas_register_ha() and request_irq() all jump to err_out_shost on error,
where the host is removed with scsi_remove_host() but its reference is
never dropped. A failed probe therefore leaves the host allocated for
good.

Put the host after removing it.

Fixes: dd4969a892ea ("[SCSI] mvsas: split driver into multiple files")
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/mvsas/mv_init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 5abc17a2e261..9210cb0bb2c1 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -571,6 +571,7 @@ static int mvs_pci_init(struct pci_dev *pdev, const struct pci_device_id *ent)
 	sas_unregister_ha(SHOST_TO_SAS_HA(shost));
 err_out_shost:
 	scsi_remove_host(mvi->shost);
+	scsi_host_put(shost);
 err_out_regions:
 	pci_release_regions(pdev);
 err_out_disable:
-- 
2.34.1


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

end of thread, other threads:[~2026-11-04  7:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:14 [PATCH] scsi: mvsas: put the Scsi_Host when host setup fails Wentao Liang
2026-11-04  2:27 ` sashiko-bot
2026-11-04  7:12 ` Krzysztof Kozlowski

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