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: [email protected]
Fixes: 559a285816af ("drm/amdgpu: Replace 'amdgpu_job_submit_direct' with 
'drm_sched_entity' in cleaner shader")
Signed-off-by: Wentao Liang <[email protected]>
---
 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 */
-- 
2.39.5 (Apple Git-154)

Reply via email to