summaryrefslogtreecommitdiff
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorMike Christie <michael.christie@oracle.com>2023-10-04 16:00:09 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2023-10-13 16:36:20 -0400
commitadd2c24d32a38402dfec3c1465f332ab8a769890 (patch)
tree4cc37ad77f2c7c39dff2f490f6355276d8c2318c /drivers/scsi/sd.c
parent0b149cee836aa53989ea089af1cb9d90d7c6ac9e (diff)
downloadlwn-add2c24d32a38402dfec3c1465f332ab8a769890.tar.gz
lwn-add2c24d32a38402dfec3c1465f332ab8a769890.zip
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 <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20231004210013.5601-9-michael.christie@oracle.com Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin Wilck <mwilck@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index dde9b6707980..674e844aa72c 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2890,7 +2890,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
}
bad_sense:
- if (scsi_sense_valid(&sshdr) &&
+ if (res == -EIO && scsi_sense_valid(&sshdr) &&
sshdr.sense_key == ILLEGAL_REQUEST &&
sshdr.asc == 0x24 && sshdr.ascq == 0x0)
/* Invalid field in CDB */
@@ -2938,7 +2938,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
sd_first_printk(KERN_WARNING, sdkp,
"getting Control mode page failed, assume no ATO\n");
- if (scsi_sense_valid(&sshdr))
+ if (res == -EIO && scsi_sense_valid(&sshdr))
sd_print_sense_hdr(sdkp, &sshdr);
return;