* [PATCH v4] drm/amdgpu: Fix resource leak in amdgpu_gfx_run_cleaner_shader_job()
@ 2026-06-24 12:47 Wentao Liang
2026-06-27 5:53 ` Mario Limonciello
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-06-24 12:47 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter
Cc: Lijo Lazar, Mario Limonciello, Aurabindo Pillai, Xiaogang Chen,
amd-gfx, dri-devel, linux-kernel, Wentao Liang, stable
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@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 | 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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v4] drm/amdgpu: Fix resource leak in amdgpu_gfx_run_cleaner_shader_job()
2026-06-24 12:47 [PATCH v4] drm/amdgpu: Fix resource leak in amdgpu_gfx_run_cleaner_shader_job() Wentao Liang
@ 2026-06-27 5:53 ` Mario Limonciello
0 siblings, 0 replies; 2+ messages in thread
From: Mario Limonciello @ 2026-06-27 5:53 UTC (permalink / raw)
To: Wentao Liang, Alex Deucher, Christian König, David Airlie,
Simona Vetter
Cc: Lijo Lazar, Aurabindo Pillai, Xiaogang Chen, amd-gfx, dri-devel,
linux-kernel, stable
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@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 | 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-27 5:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-24 12:47 [PATCH v4] drm/amdgpu: Fix resource leak in amdgpu_gfx_run_cleaner_shader_job() Wentao Liang
2026-06-27 5:53 ` Mario Limonciello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome