Skip to content

Commit 14be351

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: ufs: core: Fix an error handler crash
The UFS error handler may be activated before SCSI scanning has started and hence before hba->ufs_device_wlun has been set. Check the hba->ufs_device_wlun pointer before using it. Cc: Peter Wang <peter.wang@mediatek.com> Cc: Nitin Rawat <nitin.rawat@oss.qualcomm.com> Fixes: e23ef4f ("scsi: ufs: core: Fix error handler host_sem issue") Fixes: f966e02 ("scsi: ufs: core: Fix runtime suspend error deadlock") Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Peter Wang <peter.wang@mediatek.com> Reviewed-by: Nitin Rawat <nitin.rawat@oss.qualcomm.com> Tested-by: Nitin Rawat <nitin.rawat@oss.qualcomm.com> #SM8750 Link: https://patch.msgid.link/20251204170457.994851-1-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 278712d commit 14be351

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

drivers/ufs/core/ufshcd.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6699,19 +6699,22 @@ static void ufshcd_err_handler(struct work_struct *work)
66996699
hba->saved_uic_err, hba->force_reset,
67006700
ufshcd_is_link_broken(hba) ? "; link is broken" : "");
67016701

6702-
/*
6703-
* Use ufshcd_rpm_get_noresume() here to safely perform link recovery
6704-
* even if an error occurs during runtime suspend or runtime resume.
6705-
* This avoids potential deadlocks that could happen if we tried to
6706-
* resume the device while a PM operation is already in progress.
6707-
*/
6708-
ufshcd_rpm_get_noresume(hba);
6709-
if (hba->pm_op_in_progress) {
6710-
ufshcd_link_recovery(hba);
6702+
if (hba->ufs_device_wlun) {
6703+
/*
6704+
* Use ufshcd_rpm_get_noresume() here to safely perform link
6705+
* recovery even if an error occurs during runtime suspend or
6706+
* runtime resume. This avoids potential deadlocks that could
6707+
* happen if we tried to resume the device while a PM operation
6708+
* is already in progress.
6709+
*/
6710+
ufshcd_rpm_get_noresume(hba);
6711+
if (hba->pm_op_in_progress) {
6712+
ufshcd_link_recovery(hba);
6713+
ufshcd_rpm_put(hba);
6714+
return;
6715+
}
67116716
ufshcd_rpm_put(hba);
6712-
return;
67136717
}
6714-
ufshcd_rpm_put(hba);
67156718

67166719
down(&hba->host_sem);
67176720
spin_lock_irqsave(hba->host->host_lock, flags);

0 commit comments

Comments
 (0)