public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next v2] scsi: sd: Fix unsigned expression compared with zero in sd_spinup_disk()
@ 2024-07-04  3:14 Jiapeng Chong
  2024-07-04 17:43 ` Bart Van Assche
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2024-07-04  3:14 UTC (permalink / raw)
  To: James.Bottomley
  Cc: martin.petersen, linux-scsi, linux-kernel, Jiapeng Chong,
	Abaci Robot

The return value from the call to scsi_execute_cmd() is int. However, the
return value is being assigned to an unsigned int variable 'the_result',
so making 'the_result' an int.

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

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 v2:
  -Refine the title to make it more precise.

 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 related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next v2] scsi: sd: Fix unsigned expression compared with zero in sd_spinup_disk()
  2024-07-04  3:14 [PATCH -next v2] scsi: sd: Fix unsigned expression compared with zero in sd_spinup_disk() Jiapeng Chong
@ 2024-07-04 17:43 ` Bart Van Assche
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2024-07-04 17:43 UTC (permalink / raw)
  To: Jiapeng Chong, James.Bottomley
  Cc: martin.petersen, linux-scsi, linux-kernel, Abaci Robot,
	Mike Christie

On 7/3/24 8:14 PM, Jiapeng Chong wrote:
> The return value from the call to scsi_execute_cmd() is int. However, the
> return value is being assigned to an unsigned int variable 'the_result',
> so making 'the_result' an int.
> 
> ./drivers/scsi/sd.c:2333:6-16: WARNING: Unsigned expression compared with zero: the_result > 0.
> 
> 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>

The following is missing from this patch:
- An explanation of why this patch fixes a read of uninitialized data.
- Fixed: and Cc: stable tags.

Thanks,

Bart.

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04  3:14 [PATCH -next v2] scsi: sd: Fix unsigned expression compared with zero in sd_spinup_disk() Jiapeng Chong
2024-07-04 17:43 ` 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