Commit 37cc4b95 authored by Xiyu Yang's avatar Xiyu Yang Committed by Christian König

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: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/370219/Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
parent abf56fad
...@@ -300,8 +300,10 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, ...@@ -300,8 +300,10 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
break; break;
case -EBUSY: case -EBUSY:
case -ERESTARTSYS: case -ERESTARTSYS:
dma_fence_put(moving);
return VM_FAULT_NOPAGE; return VM_FAULT_NOPAGE;
default: default:
dma_fence_put(moving);
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment