summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <robdclark@chromium.org>2025-05-14 09:33:32 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-07-10 15:57:46 +0200
commit5deab0fa6cfd0cd7def17598db15ceb84f950584 (patch)
tree02347a6fc3b7d6e63f15bf0418f1ac44abe3aff3
parente269f29e9395527bc00c213c6b15da04ebb35070 (diff)
downloadlinux-5deab0fa6cfd0cd7def17598db15ceb84f950584.tar.gz
linux-5deab0fa6cfd0cd7def17598db15ceb84f950584.tar.bz2
linux-5deab0fa6cfd0cd7def17598db15ceb84f950584.zip
drm/msm: Fix a fence leak in submit error path
[ Upstream commit 5d319f75ccf7f0927425a7545aa1a22b3eedc189 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/gpu/drm/msm/msm_gem_submit.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index fc2fb1019ea1..2ffb2ca88ffe 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -76,6 +76,15 @@ void __msm_gem_submit_destroy(struct kref *kref)
struct dma_fence *fence;
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) {
mutex_lock(&submit->queue->lock);
idr_remove(&submit->queue->fence_idr, submit->fence_id);