scsi: hisi_sas: Add some checks to avoid free'ing a sas_task twice
authorXiang Chen <chenxiang66@hisilicon.com>
Wed, 2 May 2018 15:56:25 +0000 (23:56 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 8 May 2018 05:10:43 +0000 (01:10 -0400)
commitb81b6cce58b7912e0d35f0b5bf526cb798f8e7aa
treeaef275e688d556298f1008bd1335fa770aff6e17
parent24cf43612d4d851e660ac85f36cf389650c5a3ba
scsi: hisi_sas: Add some checks to avoid free'ing a sas_task twice

If the SCSI host enters EH, any pending IO will be processed by SCSI
EH. However it is possible that SCSI EH will try to abort the IO and
also at the same time the IO completes in the driver. In this situation
there is a small chance of freeing the sas_task twice.

Then if another IO re-uses freed sas_task before the second time of
free'ing sas_task, it is possible to free incorrect sas_task.

To avoid this situation, add some checks to increase reliability.  The
sas_task task state flag SAS_TASK_STATE_ABORTED is used to mutually
protect the LLDD and libsas freeing the task.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c