[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a494dbe2-7f6e-20d2-cd3c-1ef247349053@amd.com>
Date: Mon, 15 Jun 2020 10:55:25 +0200
From: Christian König <christian.koenig@....com>
To: Xiyu Yang <xiyuyang19@...an.edu.cn>, Huang Rui <ray.huang@....com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Sumit Semwal <sumit.semwal@...aro.org>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org, linaro-mm-sig@...ts.linaro.org
Cc: yuanxzhang@...an.edu.cn, kjlu@....edu,
Xin Tan <tanxin.ctf@...il.com>
Subject: Re: [PATCH] drm/ttm: Fix dma_fence refcnt leak when adding move fence
Am 13.06.20 um 14:30 schrieb Xiyu Yang:
> ttm_bo_add_move_fence() invokes dma_fence_get(), which returns a
> reference of the specified dma_fence object to "fence" with increased
> refcnt.
>
> When ttm_bo_add_move_fence() returns, local variable "fence" becomes
> invalid, so the refcount should be decreased to keep refcount balanced.
>
> The reference counting issue happens in one exception handling path of
> ttm_bo_add_move_fence(). When no_wait_gpu flag is equals to true, the
> function forgets to decrease the refcnt increased by dma_fence_get(),
> causing a refcnt leak.
>
> Fix this issue by calling dma_fence_put() when no_wait_gpu flag is
> equals to true.
>
> Signed-off-by: Xiyu Yang <xiyuyang19@...an.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@...il.com>
Reviewed and pushed this one as well as the other ttm fix to drm-misc-fixes.
That should show up in Linus tree rather soon.
Thanks for the help,
Christian.
PS: Are you working on some new automated scripts to catch that stuff or
how did you stumbled over it?
> ---
> drivers/gpu/drm/ttm/ttm_bo.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index f73b81c2576e..0f20e14a4cfd 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -883,8 +883,10 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
> if (!fence)
> return 0;
>
> - if (no_wait_gpu)
> + if (no_wait_gpu) {
> + dma_fence_put(fence);
> return -EBUSY;
> + }
>
> dma_resv_add_shared_fence(bo->base.resv, fence);
>
Powered by blists - more mailing lists