Skip to content

Commit bd593bd

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: sd: Fix sshdr use in read_capacity_16
If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0. Signed-off-by: Mike Christie <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: John Garry <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Martin Wilck <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 0bb80ec commit bd593bd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/scsi/sd.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,11 +2388,10 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
23882388
the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN,
23892389
buffer, RC16_LEN, SD_TIMEOUT,
23902390
sdkp->max_retries, &exec_args);
2391-
2392-
if (media_not_present(sdkp, &sshdr))
2393-
return -ENODEV;
2394-
23952391
if (the_result > 0) {
2392+
if (media_not_present(sdkp, &sshdr))
2393+
return -ENODEV;
2394+
23962395
sense_valid = scsi_sense_valid(&sshdr);
23972396
if (sense_valid &&
23982397
sshdr.sense_key == ILLEGAL_REQUEST &&

0 commit comments

Comments
 (0)