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 <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20231004210013.5601-7-michael.christie@oracle.com Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Martin Wilck <mwilck@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 87e145a commit 0b149ce

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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)