Skip to content

Commit 87e145a

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: rdac: 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Martin Wilck <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 2274bd5 commit 87e145a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/scsi/device_handler/scsi_dh_rdac.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ static void send_mode_select(struct work_struct *work)
530530
container_of(work, struct rdac_controller, ms_work);
531531
struct scsi_device *sdev = ctlr->ms_sdev;
532532
struct rdac_dh_data *h = sdev->handler_data;
533-
int err, retry_cnt = RDAC_RETRY_COUNT;
533+
int rc, err, retry_cnt = RDAC_RETRY_COUNT;
534534
struct rdac_queue_data *tmp, *qdata;
535535
LIST_HEAD(list);
536536
unsigned char cdb[MAX_COMMAND_SIZE];
@@ -558,13 +558,16 @@ static void send_mode_select(struct work_struct *work)
558558
(char *) h->ctlr->array_name, h->ctlr->index,
559559
(retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying");
560560

561-
if (!scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size,
562-
RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args)) {
561+
rc = scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size,
562+
RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args);
563+
if (!rc) {
563564
h->state = RDAC_STATE_ACTIVE;
564565
RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, "
565566
"MODE_SELECT completed",
566567
(char *) h->ctlr->array_name, h->ctlr->index);
567568
err = SCSI_DH_OK;
569+
} else if (rc < 0) {
570+
err = SCSI_DH_IO;
568571
} else {
569572
err = mode_select_handle_sense(sdev, &sshdr);
570573
if (err == SCSI_DH_RETRY && retry_cnt--)

0 commit comments

Comments
 (0)