mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Wentao Liang <vulab@iscas.ac.cn>,
	alexander.deucher@amd.com, airlied@gmail.com, simona@ffwll.ch
Cc: lijo.lazar@amd.com, aurabindo.pillai@amd.com, superm1@kernel.org,
	xiaogang.chen@amd.com, chongli2@amd.com,
	pierre-eric.pelloux-prayer@amd.com, Victor.Zhao@amd.com,
	Jesse.Zhang@amd.com, lang.yu@amd.com, Jack.Xiao@amd.com,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] drm/amdgpu: fix fence reference leak in amdgpu_gfx_run_cleaner_shader_job
Date: Wed, 17 Jun 2026 10:42:08 +0200	[thread overview]
Message-ID: <b65e026c-6864-478e-856d-9acfc254a5f9@amd.com> (raw)
In-Reply-To: <20260616153506.1713376-1-vulab@iscas.ac.cn>



On 6/16/26 17:35, Wentao Liang wrote:
> In amdgpu_gfx_run_cleaner_shader_job(), amdgpu_job_submit() returns a
> dma_fence with an elevated reference count. The function correctly
> releases this reference on the success path after dma_fence_wait().
> However, if dma_fence_wait() fails (though with infinite timeout and
> non-interruptible it never does), the code jumps to the error label
> without calling dma_fence_put(), resulting in a reference leak.
> 
> Fix the potential leak by adding dma_fence_put(f) before the goto err
> when dma_fence_wait() returns an error.
> 
> Fixes: 559a285816af ("drm/amdgpu: Replace 'amdgpu_job_submit_direct' with 'drm_sched_entity' in cleaner shader")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> v2: Also cleanup the scheduler entity and simplify error handling paths.
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> index b8ca876694ff..be13ce6ce377 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;
>  	}
>  
>  	/*
> @@ -1686,16 +1686,13 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring)
>  	f = amdgpu_job_submit(job);
>  
>  	r = dma_fence_wait(f, false);

I would just drop checking the error code here. A non interruptible dma_fence_wait() can never fail.

> -	if (r)
> -		goto err;
> +	goto err;

That goto does looks correct to me. You are now always skipping the dma_fence_put(f) below.

Regards,
Christian.

>  
>  	dma_fence_put(f);
>  
> +err:
>  	/* Clean up the scheduler entity */
>  	drm_sched_entity_destroy(&entity);
> -	return 0;
> -
> -err:
>  	return r;
>  }
>  


      reply	other threads:[~2026-06-17  8:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 15:35 Wentao Liang
2026-06-17  8:42 ` Christian König [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b65e026c-6864-478e-856d-9acfc254a5f9@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Jack.Xiao@amd.com \
    --cc=Jesse.Zhang@amd.com \
    --cc=Victor.Zhao@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chongli2@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lang.yu@amd.com \
    --cc=lijo.lazar@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-eric.pelloux-prayer@amd.com \
    --cc=simona@ffwll.ch \
    --cc=stable@vger.kernel.org \
    --cc=superm1@kernel.org \
    --cc=vulab@iscas.ac.cn \
    --cc=xiaogang.chen@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®