diff mbox series

[v5,02/13] scsi: core: need to check the result of scsi_execute in scsi_test_unit_ready

Message ID 1571387071-28853-3-git-send-email-zhengbin13@huawei.com (mailing list archive)
State Changes Requested
Headers show
Series scsi: core: fix uninit-value access of variable sshdr | expand

Commit Message

Zheng Bin 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_lib.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.7.4
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 5447738..2970190 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2216,6 +2216,9 @@  scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
 	do {
 		result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr,
 					  timeout, 1, NULL);
+		if (driver_byte(result) != DRIVER_SENSE)
+			break;
+
 		if (sdev->removable && scsi_sense_valid(sshdr) &&
 		    sshdr->sense_key == UNIT_ATTENTION)
 			sdev->changed = 1;