Blame SOURCES/0044-scsi-scsi-qla2xxx-Set-the-SCSI-command-result-before.patch

3c6e85
From 3dc14fede0858b4a3ad5cf01e2c0411e9b4fa9b4 Mon Sep 17 00:00:00 2001
3c6e85
From: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Date: Thu, 1 Aug 2019 15:55:04 -0400
3c6e85
Subject: [PATCH 044/124] [scsi] scsi: qla2xxx: Set the SCSI command result
3c6e85
 before calling the command done
3c6e85
3c6e85
Message-id: <20190801155618.12650-45-hmadhani@redhat.com>
3c6e85
Patchwork-id: 267820
3c6e85
O-Subject: [RHEL 7.8 e-stor PATCH 044/118] scsi: qla2xxx: Set the SCSI command result before calling the command done
3c6e85
Bugzilla: 1729270
3c6e85
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
3c6e85
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
3c6e85
3c6e85
From: Giridhar Malavali <gmalavali@marvell.com>
3c6e85
3c6e85
Bugzilla 1729270
3c6e85
3c6e85
This patch tries to address race condition between abort handler and
3c6e85
completion handler. When scsi command result is set by both abort and
3c6e85
completion handler, scsi_done() is only called after refcount on SRB
3c6e85
structure goes to zero. The abort handler sets this result prematurely even
3c6e85
when the refcount is non-zero value. Fix this by setting SCSI cmd->result
3c6e85
before scsi_done() is called.
3c6e85
3c6e85
Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
3c6e85
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3c6e85
(cherry picked from commit 740e29358e350077d18ee08700199e37b206edad)
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3c6e85
---
3c6e85
 drivers/scsi/qla2xxx/qla_os.c | 3 +--
3c6e85
 1 file changed, 1 insertion(+), 2 deletions(-)
3c6e85
3c6e85
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
3c6e85
index f5933550586d..03a760345a82 100644
3c6e85
--- a/drivers/scsi/qla2xxx/qla_os.c
3c6e85
+++ b/drivers/scsi/qla2xxx/qla_os.c
3c6e85
@@ -765,8 +765,6 @@ qla2x00_sp_compl(void *ptr, int res)
3c6e85
 	srb_t *sp = ptr;
3c6e85
 	struct scsi_cmnd *cmd = GET_CMD_SP(sp);
3c6e85
 
3c6e85
-	cmd->result = res;
3c6e85
-
3c6e85
 	if (atomic_read(&sp->ref_count) == 0) {
3c6e85
 		ql_dbg(ql_dbg_io, sp->vha, 0x3015,
3c6e85
 		    "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
3c6e85
@@ -779,6 +777,7 @@ qla2x00_sp_compl(void *ptr, int res)
3c6e85
 		return;
3c6e85
 
3c6e85
 	sp->free(sp);
3c6e85
+	cmd->result = res;
3c6e85
 	cmd->scsi_done(cmd);
3c6e85
 }
3c6e85
 
3c6e85
-- 
3c6e85
2.13.6
3c6e85