In amdgpu_gfx_run_cleaner_shader_job(), if amdgpu_job_alloc_with_ib()
fails, the function returns without destroying the scheduler entity,
causing a resource leak.

Fix this by adding drm_sched_entity_destroy() to the error path.

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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index b8ca876694ff..523b681d0da9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -1658,7 +1658,7 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct 
amdgpu_ring *ring)
                                  &sched, 1, NULL);
        if (r) {
                dev_err(adev->dev, "Failed setting up GFX kernel entity.\n");
-               goto err;
+               return r;
        }
 
        /*
@@ -1685,9 +1685,7 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct 
amdgpu_ring *ring)
 
        f = amdgpu_job_submit(job);
 
-       r = dma_fence_wait(f, false);
-       if (r)
-               goto err;
+       dma_fence_wait(f, false);
 
        dma_fence_put(f);
 
@@ -1696,6 +1694,8 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct 
amdgpu_ring *ring)
        return 0;
 
 err:
+       /* Clean up the scheduler entity */
+       drm_sched_entity_destroy(&entity);
        return r;
 }
 
-- 
2.39.5 (Apple Git-154)

Reply via email to