aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqianyi liu <[email protected]>2025-03-11 06:02:51 +0000
committerPhilipp Stanner <[email protected]>2025-03-13 08:39:06 +0000
commita952f1ab696873be124e31ce5ef964d36bce817f (patch)
tree3645501cabf7bb875c2ce9a00c305b4ceef2578b
parentdrm/dp_mst: Fix locking when skipping CSN before topology probing (diff)
downloadkernel-a952f1ab696873be124e31ce5ef964d36bce817f.tar.gz
kernel-a952f1ab696873be124e31ce5ef964d36bce817f.zip
drm/sched: Fix fence reference count leak
The last_scheduled fence leaks when an entity is being killed and adding the cleanup callback fails. Decrement the reference count of prev when dma_fence_add_callback() fails, ensuring proper balance. Cc: [email protected] # v6.2+ [phasta: add git tag info for stable kernel] Fixes: 2fdb8a8f07c2 ("drm/scheduler: rework entity flush, kill and fini") Signed-off-by: qianyi liu <[email protected]> Signed-off-by: Philipp Stanner <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
-rw-r--r--drivers/gpu/drm/scheduler/sched_entity.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index 69bcf0e99d57..da00572d7d42 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -259,9 +259,16 @@ static void drm_sched_entity_kill(struct drm_sched_entity *entity)
struct drm_sched_fence *s_fence = job->s_fence;
dma_fence_get(&s_fence->finished);
- if (!prev || dma_fence_add_callback(prev, &job->finish_cb,
- drm_sched_entity_kill_jobs_cb))
+ if (!prev ||
+ dma_fence_add_callback(prev, &job->finish_cb,
+ drm_sched_entity_kill_jobs_cb)) {
+ /*
+ * Adding callback above failed.
+ * dma_fence_put() checks for NULL.
+ */
+ dma_fence_put(prev);
drm_sched_entity_kill_jobs_cb(NULL, &job->finish_cb);
+ }
prev = &s_fence->finished;
}