drm/ttm: Fix dma_fence refcnt leak when adding move fence
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Sat, 13 Jun 2020 12:30:25 +0000 (20:30 +0800)
committerChristian König <christian.koenig@amd.com>
Mon, 15 Jun 2020 08:21:30 +0000 (10:21 +0200)
commit11425c4519e2c974a100fc984867046d905b9380
tree6b992c1153de61b28ebc7fa5069b7e80219c8819
parent37cc4b95d13f311c04aa8e9daacca3905ad45ca7
drm/ttm: Fix dma_fence refcnt leak when adding move fence

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@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/370221/
Signed-off-by: Christian König <christian.koenig@amd.com>
drivers/gpu/drm/ttm/ttm_bo.c