[PATCH v3] scsi: myrb: Fix region leak in hw_init functions

Hongling Zeng posted 1 patch 4 days, 21 hours ago
drivers/scsi/myrb.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH v3] scsi: myrb: Fix region leak in hw_init functions
Posted by Hongling Zeng 4 days, 21 hours ago
When request_region() fails in DAC960_PD_hw_init() and DAC960_P_hw_init(),
cb->io_addr remains non-zero. This causes myrb_cleanup() to attempt
releasing a region that was never successfully acquired, which can trigger
kernel warnings or attempt to release another driver's resources.

Fix this by clearing cb->io_addr when request_region() fails, allowing
myrb_cleanup() to properly skip the release.

Fixes: 081ff398c56c ("scsi: myrb: Add Mylex RAID controller (block interface)")
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>

---
Change in v3:
-correct the message.
---
Change in v2:
-The fix is to clear cb->io_addr when request_region() fails, matching
 the same fix already applied to DAC960_P_hw_init.
---
 drivers/scsi/myrb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index 3678b66310ed..591ba70a0579 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -3115,6 +3115,7 @@ static int DAC960_PD_hw_init(struct pci_dev *pdev,
 	if (!request_region(cb->io_addr, 0x80, "myrb")) {
 		dev_err(&pdev->dev, "IO port 0x%lx busy\n",
 			(unsigned long)cb->io_addr);
+		cb->io_addr = 0;
 		return -EBUSY;
 	}
 	DAC960_PD_disable_intr(base);
@@ -3281,6 +3282,7 @@ static int DAC960_P_hw_init(struct pci_dev *pdev,
 	if (!request_region(cb->io_addr, 0x80, "myrb")) {
 		dev_err(&pdev->dev, "IO port 0x%lx busy\n",
 			(unsigned long)cb->io_addr);
+		cb->io_addr = 0;
 		return -EBUSY;
 	}
 	DAC960_PD_disable_intr(base);
-- 
2.25.1