Skip to content

Commit add2c24

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: sd: Fix scsi_mode_sense caller's sshdr use
The sshdr passed into scsi_execute_cmd is only initialized if scsi_execute_cmd returns >= 0, and scsi_mode_sense will convert all non good statuses like check conditions to -EIO. This has scsi_mode_sense callers that were possibly accessing an uninitialized sshdrs to only access it if we got -EIO. Signed-off-by: Mike Christie <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Martin Wilck <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 0b149ce commit add2c24

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/scsi/sd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,7 +2890,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
28902890
}
28912891

28922892
bad_sense:
2893-
if (scsi_sense_valid(&sshdr) &&
2893+
if (res == -EIO && scsi_sense_valid(&sshdr) &&
28942894
sshdr.sense_key == ILLEGAL_REQUEST &&
28952895
sshdr.asc == 0x24 && sshdr.ascq == 0x0)
28962896
/* Invalid field in CDB */
@@ -2938,7 +2938,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
29382938
sd_first_printk(KERN_WARNING, sdkp,
29392939
"getting Control mode page failed, assume no ATO\n");
29402940

2941-
if (scsi_sense_valid(&sshdr))
2941+
if (res == -EIO && scsi_sense_valid(&sshdr))
29422942
sd_print_sense_hdr(sdkp, &sshdr);
29432943

29442944
return;

0 commit comments

Comments
 (0)