]> www.infradead.org Git - users/griffoul/linux.git/commitdiff
accel/ivpu: Prevent recovery work from being queued during device removal
authorKarol Wachowski <karol.wachowski@intel.com>
Fri, 8 Aug 2025 11:09:39 +0000 (13:09 +0200)
committerJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Mon, 1 Sep 2025 10:37:21 +0000 (12:37 +0200)
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: 58cde80f45a2 ("accel/ivpu: Use dedicated work for job timeout detection")
Cc: stable@vger.kernel.org # v6.8+
Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Link: https://lore.kernel.org/r/20250808110939.328366-1-jacek.lawrynowicz@linux.intel.com
drivers/accel/ivpu/ivpu_drv.c
drivers/accel/ivpu/ivpu_pm.c
drivers/accel/ivpu/ivpu_pm.h

index 3d6d52492536aab26ae44b39cacf0207fd98f77a..3289751b475733584b0c965133c9e68885749e51 100644 (file)
@@ -677,7 +677,7 @@ static void ivpu_bo_unbind_all_user_contexts(struct ivpu_device *vdev)
 static void ivpu_dev_fini(struct ivpu_device *vdev)
 {
        ivpu_jobs_abort_all(vdev);
-       ivpu_pm_cancel_recovery(vdev);
+       ivpu_pm_disable_recovery(vdev);
        ivpu_pm_disable(vdev);
        ivpu_prepare_for_reset(vdev);
        ivpu_shutdown(vdev);
index eacda1dbe84057399fa90ea4f9c71854905ab35e..475ddc94f1cfe3181ce547d6dae937e8dc9a4f77 100644 (file)
@@ -417,10 +417,10 @@ void ivpu_pm_init(struct ivpu_device *vdev)
        ivpu_dbg(vdev, PM, "Autosuspend delay = %d\n", delay);
 }
 
-void ivpu_pm_cancel_recovery(struct ivpu_device *vdev)
+void ivpu_pm_disable_recovery(struct ivpu_device *vdev)
 {
        drm_WARN_ON(&vdev->drm, delayed_work_pending(&vdev->pm->job_timeout_work));
-       cancel_work_sync(&vdev->pm->recovery_work);
+       disable_work_sync(&vdev->pm->recovery_work);
 }
 
 void ivpu_pm_enable(struct ivpu_device *vdev)
index 89b264cc0e3e785cb62182d55ccaa1050d9f1633..a2aa7a27f32ef820f5a8b73dc6cc2e4e38a2a34f 100644 (file)
@@ -25,7 +25,7 @@ struct ivpu_pm_info {
 void ivpu_pm_init(struct ivpu_device *vdev);
 void ivpu_pm_enable(struct ivpu_device *vdev);
 void ivpu_pm_disable(struct ivpu_device *vdev);
-void ivpu_pm_cancel_recovery(struct ivpu_device *vdev);
+void ivpu_pm_disable_recovery(struct ivpu_device *vdev);
 
 int ivpu_pm_suspend_cb(struct device *dev);
 int ivpu_pm_resume_cb(struct device *dev);