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

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