[v5,10/13] scsi: scsi_transport_spi: need to check whether sshdr is valid in spi_execute
diff mbox series

Message ID 1571387071-28853-11-git-send-email-zhengbin13@huawei.com
State Changes Requested
Headers show
Series
  • scsi: core: fix uninit-value access of variable sshdr
Related show

Commit Message

zhengbin Oct. 18, 2019, 8:24 a.m. UTC
Like sd_pr_command, before use sshdr, we need to check whether
sshdr is valid.

Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 drivers/scsi/scsi_transport_spi.c | 1 +
 1 file changed, 1 insertion(+)

--
2.7.4

Patch
diff mbox series

diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index f866106..428f9b8 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -124,6 +124,7 @@  static int spi_execute(struct scsi_device *sdev, const void *cmd,
 				      REQ_FAILFAST_DRIVER,
 				      0, NULL);
 		if (driver_byte(result) != DRIVER_SENSE ||
+		    !scsi_sense_valid(sshdr) ||
 		    sshdr->sense_key != UNIT_ATTENTION)
 			break;
 	}