Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Lin Yi and committed by
Alex Deucher
543c364d 45339336

+3 -1
+3 -1
drivers/gpu/drm/ttm/ttm_bo.c
··· 876 876 reservation_object_add_shared_fence(bo->resv, fence); 877 877 878 878 ret = reservation_object_reserve_shared(bo->resv, 1); 879 - if (unlikely(ret)) 879 + if (unlikely(ret)) { 880 + dma_fence_put(fence); 880 881 return ret; 882 + } 881 883 882 884 dma_fence_put(bo->moving); 883 885 bo->moving = fence;