]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/msm: Fix a fence leak in submit error path
authorRob Clark <robdclark@chromium.org>
Wed, 14 May 2025 16:33:32 +0000 (09:33 -0700)
committerRob Clark <robin.clark@oss.qualcomm.com>
Mon, 9 Jun 2025 18:27:28 +0000 (11:27 -0700)
In error paths, we could unref the submit without calling
drm_sched_entity_push_job(), so msm_job_free() will never get
called.  Since drm_sched_job_cleanup() will NULL out the
s_fence, we can use that to detect this case.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Patchwork: https://patchwork.freedesktop.org/patch/653584/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
drivers/gpu/drm/msm/msm_gem_submit.c

index 3e9aa2cc38ef9952cfd57ae775e548ed70ddcfd8..b2aeaecaa39b38241b2436e9a4c0e6a80c66eb2d 100644 (file)
@@ -85,6 +85,15 @@ void __msm_gem_submit_destroy(struct kref *kref)
                        container_of(kref, struct msm_gem_submit, ref);
        unsigned i;
 
+       /*
+        * In error paths, we could unref the submit without calling
+        * drm_sched_entity_push_job(), so msm_job_free() will never
+        * get called.  Since drm_sched_job_cleanup() will NULL out
+        * s_fence, we can use that to detect this case.
+        */
+       if (submit->base.s_fence)
+               drm_sched_job_cleanup(&submit->base);
+
        if (submit->fence_id) {
                spin_lock(&submit->queue->idr_lock);
                idr_remove(&submit->queue->fence_idr, submit->fence_id);