Skip to contentSkip to conversation

drivers: scsi: 3w-xxxx: Add error handling for initialization failure in `tw_probe`

PATCH Applied Yuchen Yang 2 participants 3 messages May 5, 2023 – Jun 1, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: scsi: 3w-xxxx: Add error handling for initialization failure in `tw_probe`

Smatch complains that:
tw_probe() warn: missing error code 'retval'

This patch adds error checking to tw_probe function to handle initialization failure. If tw_reset_sequence function returns a non-zero value, the function will return an -EINVAL error code to indicate the initialization failure.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

---
The issue is found by static analyzer. The patched code has passed Smatch checker, but remains untested on real device.

---
 drivers/scsi/3w-xxxx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/3w-xxxx.c +3 -1
index 36c34ced0cc1..641b8a2bbbd5 100644
@@ -2305,8 +2305,10 @@ static int tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
 	TW_DISABLE_INTERRUPTS(tw_dev);
 
 	/* Initialize the card */
-	if (tw_reset_sequence(tw_dev))
+	if (tw_reset_sequence(tw_dev)) {
+		retval = -EINVAL;
 		goto out_release_mem_region;
+	}
 
 	/* Set host specific parameters */
 	host->max_id = TW_MAX_UNITS;
Signature · 1 line
2.25.1
#1 lore raw

Yuchen,

Quoted 11 lines

Smatch complains that:
tw_probe() warn: missing error code 'retval'

This patch adds error checking to tw_probe function to handle initialization failure. If tw_reset_sequence function returns a non-zero value, the function will return an -EINVAL error code to indicate the initialization failure.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

Applied to 6.5/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#2 lore raw
In reply to Yuchen Yang
Quoted 9 lines · Yuchen Yang

Smatch complains that:
tw_probe() warn: missing error code 'retval'

This patch adds error checking to tw_probe function to handle initialization failure. If tw_reset_sequence function returns a non-zero value, the function will return an -EINVAL error code to indicate the initialization failure.

[...]

Applied to 6.5/scsi-queue, thanks!

[1/1] drivers: scsi: 3w-xxxx: Add error handling for initialization failure in tw_probe

      https://git.kernel.org/mkp/scsi/c/2e2fe5ac695a
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering