Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: wd719x: Fix potential firmware buffer leak on probe failure
@ 2026-11-16 14:28 Guangshuo Li
  2026-11-20  2:40 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-16 14:28 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen; +Cc: linux-scsi, linux-kernel

A failed chip initialization leaves the coherent firmware buffer behind
while probe releases the host. Disable the RISC and bus mastering before
unwinding the failed initialization, then free the firmware buffer along
with the other internal DMA buffers.

This issue was found by our static analysis tool under development.

Fixes: 48a310300663 ("wd719x: Introduce Western Digital WD7193/7197/7296 PCI SCSI card driver")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/scsi/wd719x.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
index 85cf6c9d2ec9..53c5a702ddd6 100644
--- a/drivers/scsi/wd719x.c
+++ b/drivers/scsi/wd719x.c
@@ -868,7 +868,14 @@ static int wd719x_board_found(struct Scsi_Host *sh)
 	return 0;
 
 fail_free_irq:
+	wd719x_writeb(wd, WD719X_PCI_MODE_SELECT, 0);
+	pci_clear_master(wd->pdev);
 	free_irq(wd->pdev->irq, wd);
+	if (wd->fw_virt) {
+		dma_free_coherent(&wd->pdev->dev, wd->fw_size, wd->fw_virt,
+				  wd->fw_phys);
+		wd->fw_virt = NULL;
+	}
 fail_free_hash:
 	dma_free_coherent(&wd->pdev->dev, WD719X_HASH_TABLE_SIZE, wd->hash_virt,
 			    wd->hash_phys);

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

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

end of thread, other threads:[~2026-11-20  2:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 14:28 [PATCH] scsi: wd719x: Fix potential firmware buffer leak on probe failure Guangshuo Li
2026-11-20  2:40 ` Martin K. Petersen

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