Skip to content

Commit 11425c4

Browse files
sherllyChristianKoenigAMD
authored andcommitted
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 <[email protected]> Signed-off-by: Xin Tan <[email protected]> Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/370221/ Signed-off-by: Christian König <[email protected]>
1 parent 37cc4b9 commit 11425c4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,10 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
881881
if (!fence)
882882
return 0;
883883

884-
if (no_wait_gpu)
884+
if (no_wait_gpu) {
885+
dma_fence_put(fence);
885886
return -EBUSY;
887+
}
886888

887889
dma_resv_add_shared_fence(bo->base.resv, fence);
888890

0 commit comments

Comments
 (0)