1
0
Fork 0
remarkable-linux/drivers/scsi/hisi_sas
Xiaofei Tan b61aba91eb scsi: hisi_sas: fix the risk of freeing slot twice
[ Upstream commit 6ba0fbc35a ]

The function hisi_sas_slot_task_free() is used to free the slot and do
tidy-up of LLDD resources. The LLDD generally should know the state of
a slot and decide when to free it, and it should only be done once.

For some scenarios, we really don't know the state, like when TMF
timeout. In this case, we check task->lldd_task before calling
hisi_sas_slot_task_free().

However, we may miss some scenarios when we should also check
task->lldd_task, and it is not SMP safe to check task->lldd_task as we
don't protect it within spin lock.

This patch is to fix this risk of freeing slot twice, as follows:

  1. Check task->lldd_task in the hisi_sas_slot_task_free(), and give
     up freeing of this time if task->lldd_task is NULL.

  2. Set slot->buf to NULL after it is freed.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-20 10:10:32 +01:00
..
Kconfig scsi: hisi_sas: add skeleton v3 hw driver 2017-06-19 21:31:25 -04:00
Makefile scsi: hisi_sas: add skeleton v3 hw driver 2017-06-19 21:31:25 -04:00
hisi_sas.h scsi: hisi_sas: remove driver versioning 2017-08-24 22:28:50 -04:00
hisi_sas_main.c scsi: hisi_sas: fix the risk of freeing slot twice 2017-12-20 10:10:32 +01:00
hisi_sas_v1_hw.c scsi: hisi_sas: optimise DMA slot memory 2017-07-01 17:06:56 -04:00
hisi_sas_v2_hw.c scsi: hisi_sas: add reset handler for v3 hw 2017-08-24 22:28:47 -04:00
hisi_sas_v3_hw.c scsi: hisi_sas: remove driver versioning 2017-08-24 22:28:50 -04:00