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

drm/amdgpu: fix double reference dropping

The reference to object fence is dropped at the end of the loop.
However, it is dropped again outside the loop. The reference can be
dropped immediately after calling dma_fence_wait() in the loop and
thus the dropping operation outside the loop can be removed.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Pan Bian and committed by
Alex Deucher
365f7f8d d9420705

+2 -4
+2 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
··· 33 33 { 34 34 unsigned long start_jiffies; 35 35 unsigned long end_jiffies; 36 - struct dma_fence *fence = NULL; 36 + struct dma_fence *fence; 37 37 int i, r; 38 38 39 39 start_jiffies = jiffies; ··· 44 44 if (r) 45 45 goto exit_do_move; 46 46 r = dma_fence_wait(fence, false); 47 + dma_fence_put(fence); 47 48 if (r) 48 49 goto exit_do_move; 49 - dma_fence_put(fence); 50 50 } 51 51 end_jiffies = jiffies; 52 52 r = jiffies_to_msecs(end_jiffies - start_jiffies); 53 53 54 54 exit_do_move: 55 - if (fence) 56 - dma_fence_put(fence); 57 55 return r; 58 56 } 59 57