Re: [PATCH v4] drm/amdgpu: Fix resource leak in amdgpu_gfx_run_cleaner_shader_job()
From: Mario Limonciello
Date: Sat Jun 27 2026 - 01:54:04 EST
On 6/24/26 07:47, Wentao Liang wrote:
When amdgpu_job_alloc_with_ib() fails in
amdgpu_gfx_run_cleaner_shader_job(), the function returns directly
without destroying the scheduler entity, causing a resource leak.
Fix this by moving the entity cleanup to a common error path. Set r = 0
on success and use a single cleanup point at the err label to ensure the
entity is always destroyed regardless of whether the function succeeds
or fails.
Also remove the unnecessary error check for dma_fence_wait() since it
never fails with intr=false and infinite timeout.
Cc: stable@xxxxxxxxxxxxxxx
Fixes: 559a285816af ("drm/amdgpu: Replace 'amdgpu_job_submit_direct' with 'drm_sched_entity' in cleaner shader")
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 523b681d0da9..29a07af6f5f4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -1689,9 +1689,7 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring)
dma_fence_put(f);
- /* Clean up the scheduler entity */
- drm_sched_entity_destroy(&entity);
- return 0;
+ r = 0;
err:
/* Clean up the scheduler entity */
What tree is this against? It doesn't apply against amd-staging-drm-next.
Applying: drm/amdgpu: Fix resource leak in amdgpu_gfx_run_cleaner_shader_job()
Patch failed at 0001 drm/amdgpu: Fix resource leak in amdgpu_gfx_run_cleaner_shader_job()
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
error: patch failed: drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:1689
error: drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch