Skip to content

Commit 69a79ad

Browse files
kwachowsjlawryno
authored andcommitted
accel/ivpu: Prevent recovery work from being queued during device removal
Use disable_work_sync() instead of cancel_work_sync() in ivpu_dev_fini() to ensure that no new recovery work items can be queued after device removal has started. Previously, recovery work could be scheduled even after canceling existing work, potentially leading to use-after-free bugs if recovery accessed freed resources. Rename ivpu_pm_cancel_recovery() to ivpu_pm_disable_recovery() to better reflect its new behavior. Fixes: 58cde80 ("accel/ivpu: Use dedicated work for job timeout detection") Cc: [email protected] # v6.8+ Signed-off-by: Karol Wachowski <[email protected]> Reviewed-by: Lizhi Hou <[email protected]> Signed-off-by: Jacek Lawrynowicz <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2cb66ae commit 69a79ad

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

drivers/accel/ivpu/ivpu_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ static void ivpu_bo_unbind_all_user_contexts(struct ivpu_device *vdev)
677677
static void ivpu_dev_fini(struct ivpu_device *vdev)
678678
{
679679
ivpu_jobs_abort_all(vdev);
680-
ivpu_pm_cancel_recovery(vdev);
680+
ivpu_pm_disable_recovery(vdev);
681681
ivpu_pm_disable(vdev);
682682
ivpu_prepare_for_reset(vdev);
683683
ivpu_shutdown(vdev);

drivers/accel/ivpu/ivpu_pm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,10 @@ void ivpu_pm_init(struct ivpu_device *vdev)
417417
ivpu_dbg(vdev, PM, "Autosuspend delay = %d\n", delay);
418418
}
419419

420-
void ivpu_pm_cancel_recovery(struct ivpu_device *vdev)
420+
void ivpu_pm_disable_recovery(struct ivpu_device *vdev)
421421
{
422422
drm_WARN_ON(&vdev->drm, delayed_work_pending(&vdev->pm->job_timeout_work));
423-
cancel_work_sync(&vdev->pm->recovery_work);
423+
disable_work_sync(&vdev->pm->recovery_work);
424424
}
425425

426426
void ivpu_pm_enable(struct ivpu_device *vdev)

drivers/accel/ivpu/ivpu_pm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct ivpu_pm_info {
2525
void ivpu_pm_init(struct ivpu_device *vdev);
2626
void ivpu_pm_enable(struct ivpu_device *vdev);
2727
void ivpu_pm_disable(struct ivpu_device *vdev);
28-
void ivpu_pm_cancel_recovery(struct ivpu_device *vdev);
28+
void ivpu_pm_disable_recovery(struct ivpu_device *vdev);
2929

3030
int ivpu_pm_suspend_cb(struct device *dev);
3131
int ivpu_pm_resume_cb(struct device *dev);

0 commit comments

Comments
 (0)