scsi: pm80xx: Fix TMF task completion race condition
authorIgor Pylypiv <ipylypiv@google.com>
Wed, 7 Jul 2021 18:59:45 +0000 (11:59 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 29 Jul 2021 03:29:09 +0000 (23:29 -0400)
commitd712d3fb484b7fa8d1d57e9ca6f134bb9d8c18b1
treeb309c6d514e869fefba51996e843c412314bb325
parenta47fa41381a09e5997afd762664db4f5f6657e03
scsi: pm80xx: Fix TMF task completion race condition

The TMF timeout timer may trigger at the same time when the response from a
controller is being handled. When this happens the SAS task may get freed
before the response processing is finished.

Fix this by calling complete() only when SAS_TASK_STATE_DONE is not set.

A similar race condition was fixed in commit b90cd6f2b905 ("scsi: libsas:
fix a race condition when smp task timeout")

Link: https://lore.kernel.org/r/20210707185945.35559-1-ipylypiv@google.com
Reviewed-by: Vishakha Channapattan <vishakhavc@google.com>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/pm8001/pm8001_sas.c