summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm
diff options
context:
space:
mode:
authorLin Yi <teroincn@163.com>2019-04-10 10:23:34 +0800
committerAlex Deucher <alexander.deucher@amd.com>2019-04-11 10:02:21 -0500
commit543c364d8eeeb42c0edfaac9764f4e9f3d777ec1 (patch)
tree383cf020fe70cecdfad507fd796c280ff5c4ea92 /drivers/gpu/drm/ttm
parent453393369dc9806d2455151e329c599684762428 (diff)
downloadlinux-543c364d8eeeb42c0edfaac9764f4e9f3d777ec1.tar.gz
linux-543c364d8eeeb42c0edfaac9764f4e9f3d777ec1.tar.bz2
linux-543c364d8eeeb42c0edfaac9764f4e9f3d777ec1.zip
drm/ttm: fix dma_fence refcount imbalance on error path
the ttm_bo_add_move_fence takes a reference to the struct dma_fence, but failed to release it on the error path, leading to a memory leak. add dma_fence_put before return when error occur. Signed-off-by: Lin Yi <teroincn@163.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/ttm')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3f56647cdb35..0fa5034b9f9e 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -876,8 +876,10 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
reservation_object_add_shared_fence(bo->resv, fence);
ret = reservation_object_reserve_shared(bo->resv, 1);
- if (unlikely(ret))
+ if (unlikely(ret)) {
+ dma_fence_put(fence);
return ret;
+ }
dma_fence_put(bo->moving);
bo->moving = fence;