Skip to content

Commit 886fe29

Browse files
ahunter6martinkpetersen
authored andcommitted
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/[email protected] Fixes: f5ef336 ("scsi: ufs: core: Fix task management completion") Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Adrian Hunter <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4edd8cd commit 886fe29

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

drivers/scsi/ufs/ufshcd.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6616,11 +6616,6 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
66166616
err = wait_for_completion_io_timeout(&wait,
66176617
msecs_to_jiffies(TM_CMD_TIMEOUT));
66186618
if (!err) {
6619-
/*
6620-
* Make sure that ufshcd_compl_tm() does not trigger a
6621-
* use-after-free.
6622-
*/
6623-
req->end_io_data = NULL;
66246619
ufshcd_add_tm_upiu_trace(hba, task_tag, UFS_TM_ERR);
66256620
dev_err(hba->dev, "%s: task management cmd 0x%.2x timed-out\n",
66266621
__func__, tm_function);

0 commit comments

Comments
 (0)