diff mbox series

scsi: scsi_debug: fix an error handling bug in sdeb_zbc_model_str()

Message ID 20200509100408.GA5555@mwanda (mailing list archive)
State Mainlined
Commit 47742bde281b2920aae8bb82ed2d61d890aa4f56
Headers show
Series scsi: scsi_debug: fix an error handling bug in sdeb_zbc_model_str() | expand

Commit Message

Dan Carpenter May 9, 2020, 10:04 a.m. UTC
This test is checking the wrong variable.  It should be testing "ret".
The "sdeb_zbc_model" variable is an enum (unsigned in this situation)
and we never assign negative values to it.

Fixes: 9267e0eb41fe ("scsi: scsi_debug: Add ZBC module parameter")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/scsi/scsi_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Douglas Gilbert May 9, 2020, 2:45 p.m. UTC | #1
On 2020-05-09 6:04 a.m., Dan Carpenter wrote:
> This test is checking the wrong variable.  It should be testing "ret".
> The "sdeb_zbc_model" variable is an enum (unsigned in this situation)
> and we never assign negative values to it.
> 
> Fixes: 9267e0eb41fe ("scsi: scsi_debug: Add ZBC module parameter")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

s/ret/res/ at the end of the first line above.

Acked-by: Douglas Gilbert <dgilbert@interlog.com>

> ---
>   drivers/scsi/scsi_debug.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 105e563d87b4e..73847366dc495 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -6460,7 +6460,7 @@ static int sdeb_zbc_model_str(const char *cp)
>   		res = sysfs_match_string(zbc_model_strs_b, cp);
>   		if (res < 0) {
>   			res = sysfs_match_string(zbc_model_strs_c, cp);
> -			if (sdeb_zbc_model < 0)
> +			if (res < 0)
>   				return -EINVAL;
>   		}
>   	}
>
Martin K. Petersen May 12, 2020, 3:28 a.m. UTC | #2
On Sat, 9 May 2020 13:04:08 +0300, Dan Carpenter wrote:

> This test is checking the wrong variable.  It should be testing "ret".
> The "sdeb_zbc_model" variable is an enum (unsigned in this situation)
> and we never assign negative values to it.

Applied to 5.8/scsi-queue, thanks!

[1/1] scsi: scsi_debug: Fix an error handling bug in sdeb_zbc_model_str()
      https://git.kernel.org/mkp/scsi/c/47742bde281b
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 105e563d87b4e..73847366dc495 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -6460,7 +6460,7 @@  static int sdeb_zbc_model_str(const char *cp)
 		res = sysfs_match_string(zbc_model_strs_b, cp);
 		if (res < 0) {
 			res = sysfs_match_string(zbc_model_strs_c, cp);
-			if (sdeb_zbc_model < 0)
+			if (res < 0)
 				return -EINVAL;
 		}
 	}