Commit 740e2935 authored by Giridhar Malavali's avatar Giridhar Malavali Committed by Martin K. Petersen

scsi: qla2xxx: Set the SCSI command result before calling the command done

This patch tries to address race condition between abort handler and
completion handler. When scsi command result is set by both abort and
completion handler, scsi_done() is only called after refcount on SRB
structure goes to zero. The abort handler sets this result prematurely even
when the refcount is non-zero value. Fix this by setting SCSI cmd->result
before scsi_done() is called.
Signed-off-by: default avatarGiridhar Malavali <gmalavali@marvell.com>
Signed-off-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent d6d189ce
...@@ -765,8 +765,6 @@ qla2x00_sp_compl(void *ptr, int res) ...@@ -765,8 +765,6 @@ qla2x00_sp_compl(void *ptr, int res)
srb_t *sp = ptr; srb_t *sp = ptr;
struct scsi_cmnd *cmd = GET_CMD_SP(sp); struct scsi_cmnd *cmd = GET_CMD_SP(sp);
cmd->result = res;
if (atomic_read(&sp->ref_count) == 0) { if (atomic_read(&sp->ref_count) == 0) {
ql_dbg(ql_dbg_io, sp->vha, 0x3015, ql_dbg(ql_dbg_io, sp->vha, 0x3015,
"SP reference-count to ZERO -- sp=%p cmd=%p.\n", "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
...@@ -779,6 +777,7 @@ qla2x00_sp_compl(void *ptr, int res) ...@@ -779,6 +777,7 @@ qla2x00_sp_compl(void *ptr, int res)
return; return;
sp->free(sp); sp->free(sp);
cmd->result = res;
cmd->scsi_done(cmd); cmd->scsi_done(cmd);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment