scsi: qedi: Fix race during abort timeouts
authorMike Christie <michael.christie@oracle.com>
Tue, 25 May 2021 18:18:13 +0000 (13:18 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:05:41 +0000 (16:05 +0200)
commit57fa983ea736f79cc03b3d51e8b8fb854e452542
tree84cac14d5e2ed7d4d6661a53b7ab7b3bb7a53c16
parentafa1c8ee7e630c994c1175ea320716b651e57635
scsi: qedi: Fix race during abort timeouts

[ Upstream commit 2ce002366a3fcc3f9616d4583194f65dde0ad253 ]

If the SCSI cmd completes after qedi_tmf_work calls iscsi_itt_to_task then
the qedi qedi_cmd->task_id could be freed and used for another cmd. If we
then call qedi_iscsi_cleanup_task with that task_id we will be cleaning up
the wrong cmd.

Wait to release the task_id until the last put has been done on the
iscsi_task. Because libiscsi grabs a ref to the task when sending the
abort, we know that for the non-abort timeout case that the task_id we are
referencing is for the cmd that was supposed to be aborted.

A latter commit will fix the case where the abort times out while we are
running qedi_tmf_work.

Link: https://lore.kernel.org/r/20210525181821.7617-21-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/qedi/qedi_fw.c
drivers/scsi/qedi/qedi_iscsi.c