[PATCH] drm/amd: fix memory leak in amdgpu_cs_sync_rings

Mikhail Gavrilov mikhail.v.gavrilov at gmail.com
Fri Feb 3 10:42:08 UTC 2023


On Fri, Feb 3, 2023 at 12:10 AM Bert Karwatzki <spasswolf at web.de> wrote:
>
> I hope I got it right this time:
> Here is the fix for
> Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2360
>
> From 6e064c9565ef0da890f3fcb2a4f6a8cd44a12fdb Mon Sep 17 00:00:00 2001
> From: Bert Karwatzki <spasswolf at web.de>
> Date: Thu, 2 Feb 2023 19:50:27 +0100
> Subject: [PATCH] Fix memory leak in amdgpu_cs_sync_rings.
>
> Signed-off-by: Bert Karwatzki <spasswolf at web.de>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 0f4cb41078c1..08eced097bd8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -1222,10 +1222,13 @@ static int amdgpu_cs_sync_rings(struct
> amdgpu_cs_parser *p)
>                  * next job actually sees the results from the
> previous one
>                  * before we start executing on the same scheduler
> ring.
>                  */
> -               if (!s_fence || s_fence->sched != sched)
> +               if (!s_fence || s_fence->sched != sched) {
> +                       dma_fence_put(fence);
>                         continue;
> +               }
>
>                 r = amdgpu_sync_fence(&p->gang_leader->explicit_sync,
> fence);
> +               dma_fence_put(fence);
>                 if (r)
>                         return r;
>         }
> --
> 2.39.1
>

As a bug reporter I can confirm this patch fixes a memory leak.
Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov at gmail.com>

-- 
Best Regards,
Mike Gavrilov.


More information about the amd-gfx mailing list