Skip to content

Commit 37cc4b9

Browse files
sherllyChristianKoenigAMD
authored andcommitted
drm/ttm: Fix dma_fence refcnt leak in ttm_bo_vm_fault_reserved
ttm_bo_vm_fault_reserved() invokes dma_fence_get(), which returns a reference of the specified dma_fence object to "moving" with increased refcnt. When ttm_bo_vm_fault_reserved() returns, local variable "moving" becomes invalid, so the refcount should be decreased to keep refcount balanced. The reference counting issue happens in several exception handling paths of ttm_bo_vm_fault_reserved(). When those error scenarios occur such as "err" equals to -EBUSY, 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/370219/ Signed-off-by: Christian König <[email protected]>
1 parent abf56fa commit 37cc4b9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/gpu/drm/ttm/ttm_bo_vm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,10 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
300300
break;
301301
case -EBUSY:
302302
case -ERESTARTSYS:
303+
dma_fence_put(moving);
303304
return VM_FAULT_NOPAGE;
304305
default:
306+
dma_fence_put(moving);
305307
return VM_FAULT_SIGBUS;
306308
}
307309

0 commit comments

Comments
 (0)