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: Giridhar Malavali <gmalavali@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Giridhar Malavali 2019-04-02 14:24:20 -07:00 коммит произвёл Martin K. Petersen
Родитель d6d189ceab
Коммит 740e29358e
1 изменённых файлов: 1 добавлений и 2 удалений

Просмотреть файл

@ -765,8 +765,6 @@ qla2x00_sp_compl(void *ptr, int res)
srb_t *sp = ptr;
struct scsi_cmnd *cmd = GET_CMD_SP(sp);
cmd->result = res;
if (atomic_read(&sp->ref_count) == 0) {
ql_dbg(ql_dbg_io, sp->vha, 0x3015,
"SP reference-count to ZERO -- sp=%p cmd=%p.\n",
@ -779,6 +777,7 @@ qla2x00_sp_compl(void *ptr, int res)
return;
sp->free(sp);
cmd->result = res;
cmd->scsi_done(cmd);
}