* [PATCH v3] drm/amdgpu: fix scheduler entity leak in cleaner shader job
@ 2026-06-22 15:35 Wentao Liang
2026-06-22 15:52 ` Christian König
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-06-22 15:35 UTC (permalink / raw)
To: Alex Deucher, Christian König
Cc: amd-gfx, dri-devel, linux-kernel, Wentao Liang, stable
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: stable@vger.kernel.org
Fixes: 559a285816af ("drm/amdgpu: Replace 'amdgpu_job_submit_direct' with 'drm_sched_entity' in cleaner shader")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
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)
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v3] drm/amdgpu: fix scheduler entity leak in cleaner shader job
2026-06-22 15:35 [PATCH v3] drm/amdgpu: fix scheduler entity leak in cleaner shader job Wentao Liang
@ 2026-06-22 15:52 ` Christian König
0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2026-06-22 15:52 UTC (permalink / raw)
To: Wentao Liang, Alex Deucher; +Cc: amd-gfx, dri-devel, linux-kernel, stable
On 6/22/26 17:35, Wentao Liang wrote:
> 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: stable@vger.kernel.org
> Fixes: 559a285816af ("drm/amdgpu: Replace 'amdgpu_job_submit_direct' with 'drm_sched_entity' in cleaner shader")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> 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);
That is actually redundant. The err label should just be a few more lines up and the "return 0;" changed to "return r;".
Regards,
Christian.
> return r;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-22 15:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22 15:35 [PATCH v3] drm/amdgpu: fix scheduler entity leak in cleaner shader job Wentao Liang
2026-06-22 15:52 ` Christian König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®