From: Srinivasan Shanmugam Date: Sat, 28 Feb 2026 16:26:40 +0000 (+0530) Subject: drm/amdgpu: Fix mutex handling in amdgpu_benchmark_do_move() v3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5d8df53b620eb094855a2bd88be89c4bdf7a031;p=thirdparty%2Flinux.git drm/amdgpu: Fix mutex handling in amdgpu_benchmark_do_move() v3 amdgpu_benchmark_do_move() can exit the loop early if amdgpu_copy_buffer() or dma_fence_wait() fails. In the error path, the function jumps to the exit label without releasing adev->mman.default_entity.lock, which leaves the mutex held and results in a lock imbalance. This can block subsequent users of default_entity and potentially cause deadlocks. Move the mutex_unlock() to the common exit path so the lock is released on both success and error returns. This fixes: drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c:57 amdgpu_benchmark_do_move() warn: inconsistent returns '&adev->mman.default_entity.lock'. v2: - Drop unrelated initialization of 'r' - Keep the change focused on the mutex imbalance fix (Pierre). v3: - Removed empty line Fixes: 30f2daedf4d8 ("drm/amdgpu: add missing lock in amdgpu_benchmark_do_move") Reported-by: Dan Carpenter Cc: Pierre-Eric Pelloux-Prayer Cc: Christian König Cc: Alex Deucher Signed-off-by: Srinivasan Shanmugam Reviewed-by: Pierre-Eric Pelloux-Prayer Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c index 98ccd7ab9e9a3..6f3c68cde75eb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c @@ -48,9 +48,9 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size, if (r) goto exit_do_move; } - mutex_unlock(&adev->mman.default_entity.lock); exit_do_move: + mutex_unlock(&adev->mman.default_entity.lock); etime = ktime_get(); *time_ms = ktime_ms_delta(etime, stime);