]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: sd: Fix return code handling in sd_spinup_disk()
authorMike Christie <michael.christie@oracle.com>
Mon, 11 May 2026 17:53:17 +0000 (12:53 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 15 May 2026 02:02:52 +0000 (22:02 -0400)
As found by smatch-ci, scsi_execute_cmd() can return negative or positve
values so we should use a int instead of unsigned int.

Fixes: b4d0c33a32c3 ("scsi: sd: Fix sshdr use in sd_spinup_disk")
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/linux-scsi/agFbI7E6JQwd3wGW@stanley.mountain/T/#u
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20260511175317.114007-1-michael.christie@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sd.c

index adc3fa55ca2c37834f39abd9b32a50f71ed8b2ee..599e75f3333438ce1c01cc4abfdc2d73200298bb 100644 (file)
@@ -2476,8 +2476,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, spintime, sense_valid = 0;
        struct scsi_sense_hdr sshdr;
        struct scsi_failure failure_defs[] = {
                /* Do not retry Medium Not Present */