[PATCH] drm/amd: fix memory leak in amdgpu_cs_sync_rings
Alex Deucher
alexdeucher at gmail.com
Thu Feb 2 18:13:32 UTC 2023
On Thu, Feb 2, 2023 at 1:05 PM Bert Karwatzki <spasswolf at web.de> wrote:
>
> amdgpu_sync_get_fence deletes the returned fence from the syncobj, so
> the refcount of fence needs to lowered to avoid a memory leak:
> https://gitlab.freedesktop.org/drm/amd/-/issues/2360
Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2360
Please send a proper patch using git-format-patch. Also, please add
your Signed-off-by line.
With those fixed, the patch is:
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
>
> 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;
> }
>
>
> Bert Karwatzki
More information about the amd-gfx
mailing list