mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next v3] scsi: sd: Fix an incorrect type in 'sd_spinup_disk()'
@ 2024-07-09  9:39 Jiapeng Chong
  2024-07-09 17:59 ` Bart Van Assche
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2024-07-09  9:39 UTC (permalink / raw)
  To: James.Bottomley
  Cc: martin.petersen, linux-scsi, linux-kernel, Jiapeng Chong, stable,
	Abaci Robot

The return value from the call to scsi_execute_cmd() is int. In the
'else if' branch of the function scsi_execute_cmd, it will return -EINVAL.
But the type of "the_result" is "unsigned int", causing the error code to
reverse. Modify the type of "the_result" to solve this problem.

The code featuring the_result as the return value of the function
scsi_execute_cmd is as follows:

the_result = scsi_execute_cmd(sdkp->device, cmd, REQ_OP_DRV_IN, NULL, 0,
			      SD_TIMEOUT, sdkp->max_retries, &exec_args);
if (the_result > 0) {
...
}

./drivers/scsi/sd.c:2333:6-16: WARNING: Unsigned expression compared
with zero: the_result > 0.

Fixes: c1acf38cd11e ("scsi: sd: Have midlayer retry sd_spinup_disk() errors")
Cc: stable@vger.kernel.org
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9463
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
Changes in v3:
  -Amend the commit message, Add "Fixes:" and "Cc: stable" tags.

 drivers/scsi/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 979795dad62b..ade8c6cca295 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2396,7 +2396,7 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 	static const u8 cmd[10] = { TEST_UNIT_READY };
 	unsigned long spintime_expire = 0;
 	int spintime, sense_valid = 0;
-	unsigned int the_result;
+	int the_result;
 	struct scsi_sense_hdr sshdr;
 	struct scsi_failure failure_defs[] = {
 		/* Do not retry Medium Not Present */
-- 
2.20.1.7.g153144c


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

end of thread, other threads:[~2024-07-09 17:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-09  9:39 [PATCH -next v3] scsi: sd: Fix an incorrect type in 'sd_spinup_disk()' Jiapeng Chong
2024-07-09 17:59 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®