]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: ufs: core: Fix task management completion timeout race
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 8 Nov 2021 06:48:14 +0000 (08:48 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 17 Nov 2021 00:42:31 +0000 (19:42 -0500)
commitf00dd1b7ce00d7b3ae2e107eefc81b5ed37802cb
tree18d20c876f5eb81b043cb3024d49f24fbbabc99d
parent6855eb6c2ab8239161f8d1c41b8ef32f2f0f2fcd
scsi: ufs: core: Fix task management completion timeout race

__ufshcd_issue_tm_cmd() clears req->end_io_data after timing out, which
races with the completion function ufshcd_tmc_handler() which expects
req->end_io_data to have a value.

Note __ufshcd_issue_tm_cmd() and ufshcd_tmc_handler() are already
synchronized using hba->tmf_rqs and hba->outstanding_tasks under the
host_lock spinlock.

It is also not necessary (nor typical) to clear req->end_io_data because
the block layer does it before allocating out requests e.g. via
blk_get_request().

So fix by not clearing it.

Link: https://lore.kernel.org/r/20211108064815.569494-2-adrian.hunter@intel.com
Fixes: 7ea1cde92527 ("scsi: ufs: core: Fix task management completion")
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufshcd.c