[v5,03/13] scsi: core: need to check the result of scsi_execute in scsi_report_lun_scan
diff mbox series

Message ID 1571387071-28853-4-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 the result
of scsi_execute.

Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 drivers/scsi/scsi_scan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.7.4

Patch
diff mbox series

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 058079f..781f82a 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1385,7 +1385,8 @@  static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
 				retries, result));
 		if (result == 0)
 			break;
-		else if (scsi_sense_valid(&sshdr)) {
+		else if (driver_byte(result) == DRIVER_SENSE &&
+			 scsi_sense_valid(&sshdr)) {
 			if (sshdr.sense_key != UNIT_ATTENTION)
 				break;
 		}