Skip to contentSkip to conversation

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

PATCH Applied Dan Carpenter 3 participants 3 messages May 9, 2020 – May 12, 2020

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

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

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")
---
 drivers/scsi/scsi_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +1 -1
index 105e563d87b4e..73847366dc495 100644
@@ -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;
 		}
 	}
Signature · 1 line
2.26.2
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

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")

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

Quoted 18 lines
---
  drivers/scsi/scsi_debug.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +1 -1
index 105e563d87b4e..73847366dc495 100644
@@ -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;
  		}
  	}
#2 lore raw
In reply to Dan Carpenter
Quoted 3 lines · Dan Carpenter

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
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering