scsi: hisi_sas: Replace del_timer() calls with del_timer_sync()
authorXiang Chen <chenxiang66@hisilicon.com>
Tue, 24 Aug 2021 10:00:59 +0000 (18:00 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 14 Sep 2021 03:56:02 +0000 (23:56 -0400)
commit080b4f976bf7a61ae082d5ae1d2cee83b097b63a
tree714ae2c932702af9742a8cbffc67e69e63d18819
parentb5a9fa20e3bf59d89b5f48315a0c0c32963796ed
scsi: hisi_sas: Replace del_timer() calls with del_timer_sync()

Some usage of del_timer() in the driver is potentially unsafe.

When running the sas_task->slow_task timer in
hisi_sas_exec_internal_tmf_task(), execution may be blocked in function
hisi_sas_task_exec(); so it is possible that the timer is running when the
callback to disable the timer is running. This could be dangerous, as we
immediately release resources which the timer callback uses after disabling
the timer. The same situation may be found at other sites, such as
_hisi_sas_internal_task_abort().

Change calls to del_timer() to del_timer_sync() as necessary, to ensure any
timer has finished when disabling.

Also remove calls to timer_pending() prior to del_timer() as it is not
necessary.

Link: https://lore.kernel.org/r/1629799260-120116-5-git-send-email-john.garry@huawei.com
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