linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: scsi: 3w-xxxx: Add error handling for initialization failure in `tw_probe`
@ 2023-05-05 14:12 Yuchen Yang
  2023-05-22 21:40 ` Martin K. Petersen
  2023-06-01  0:43 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Yuchen Yang @ 2023-05-05 14:12 UTC (permalink / raw)
  To: Adam Radford, James E.J. Bottomley, Martin K. Petersen
  Cc: hust-os-kernel-patches, Yuchen Yang, Dan Carpenter, linux-scsi,
	linux-kernel

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")
Signed-off-by: Yuchen Yang <u202114568@hust.edu.cn>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> 
---
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(-)

diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 36c34ced0cc1..641b8a2bbbd5 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -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;
-- 
2.25.1


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

* Re: [PATCH] drivers: scsi: 3w-xxxx: Add error handling for initialization failure in `tw_probe`
  2023-05-05 14:12 [PATCH] drivers: scsi: 3w-xxxx: Add error handling for initialization failure in `tw_probe` Yuchen Yang
@ 2023-05-22 21:40 ` Martin K. Petersen
  2023-06-01  0:43 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2023-05-22 21:40 UTC (permalink / raw)
  To: Yuchen Yang
  Cc: Adam Radford, James E.J. Bottomley, Martin K. Petersen,
	hust-os-kernel-patches, Dan Carpenter, linux-scsi, linux-kernel


Yuchen,

> 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")
> Signed-off-by: Yuchen Yang <u202114568@hust.edu.cn>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> 

Applied to 6.5/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] drivers: scsi: 3w-xxxx: Add error handling for initialization failure in `tw_probe`
  2023-05-05 14:12 [PATCH] drivers: scsi: 3w-xxxx: Add error handling for initialization failure in `tw_probe` Yuchen Yang
  2023-05-22 21:40 ` Martin K. Petersen
@ 2023-06-01  0:43 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2023-06-01  0:43 UTC (permalink / raw)
  To: Adam Radford, James E.J. Bottomley, Yuchen Yang
  Cc: Martin K . Petersen, hust-os-kernel-patches, Dan Carpenter,
	linux-scsi, linux-kernel

On Fri, 05 May 2023 22:12:55 +0800, Yuchen Yang wrote:

> 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

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2023-06-01  0:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-05 14:12 [PATCH] drivers: scsi: 3w-xxxx: Add error handling for initialization failure in `tw_probe` Yuchen Yang
2023-05-22 21:40 ` Martin K. Petersen
2023-06-01  0:43 ` 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;
as well as URLs for NNTP newsgroup(s).