[v5,07/13] scsi: scsi_dh_rdac: need to check the result of scsi_execute in send_mode_select
diff mbox series

Message ID 1571387071-28853-8-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/device_handler/scsi_dh_rdac.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--
2.7.4

Patch
diff mbox series

diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 5efc959..2a43985 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -531,6 +531,7 @@  static void send_mode_select(struct work_struct *work)
 	struct scsi_device *sdev = ctlr->ms_sdev;
 	struct rdac_dh_data *h = sdev->handler_data;
 	int err = SCSI_DH_OK, retry_cnt = RDAC_RETRY_COUNT;
+	int result;
 	struct rdac_queue_data *tmp, *qdata;
 	LIST_HEAD(list);
 	unsigned char cdb[MAX_COMMAND_SIZE];
@@ -555,9 +556,10 @@  static void send_mode_select(struct work_struct *work)
 		(char *) h->ctlr->array_name, h->ctlr->index,
 		(retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying");

-	if (scsi_execute(sdev, cdb, DMA_TO_DEVICE, &h->ctlr->mode_select,
-			data_size, NULL, &sshdr, RDAC_TIMEOUT * HZ,
-			RDAC_RETRIES, req_flags, 0, NULL)) {
+	result = scsi_execute(sdev, cdb, DMA_TO_DEVICE, &h->ctlr->mode_select,
+			     data_size, NULL, &sshdr, RDAC_TIMEOUT * HZ,
+			     RDAC_RETRIES, req_flags, 0, NULL);
+	if (driver_byte(result) == DRIVER_SENSE) {
 		err = mode_select_handle_sense(sdev, &sshdr);
 		if (err == SCSI_DH_RETRY && retry_cnt--)
 			goto retry;