Skip to content

Commit 0b149ce

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: spi: Fix sshdr use
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: Martin Wilck <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 87e145a commit 0b149ce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/scsi/scsi_transport_spi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,10 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,
676676
for (r = 0; r < retries; r++) {
677677
result = spi_execute(sdev, spi_write_buffer, REQ_OP_DRV_OUT,
678678
buffer, len, &sshdr);
679-
if(result || !scsi_device_online(sdev)) {
679+
if (result || !scsi_device_online(sdev)) {
680680

681681
scsi_device_set_state(sdev, SDEV_QUIESCE);
682-
if (scsi_sense_valid(&sshdr)
682+
if (result > 0 && scsi_sense_valid(&sshdr)
683683
&& sshdr.sense_key == ILLEGAL_REQUEST
684684
/* INVALID FIELD IN CDB */
685685
&& sshdr.asc == 0x24 && sshdr.ascq == 0x00)

0 commit comments

Comments
 (0)