drm/amdgpu: fix use-after-unlock in eviction fence destroy
authorArvind Yadav <Arvind.Yadav@amd.com>
Thu, 15 May 2025 07:14:46 +0000 (12:44 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 16 May 2025 17:38:10 +0000 (13:38 -0400)
The eviction fence destroy path incorrectly calls dma_fence_put() on
evf_mgr->ev_fence after releasing the ev_fence_lock. This introduces a
potential use-after-unlock or race because another thread concurrently
modifies evf_mgr->ev_fence.

Fix this by grabbing a local reference to evf_mgr->ev_fence under the
lock and using that for dma_fence_put() after waiting.

Cc: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Sunil Khatri <sunil.khatri@amd.com>
Signed-off-by: Arvind Yadav <Arvind.Yadav@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c

index 1a7469543db577cd62fc15a08141ff60c9e69800..73b629b5f56fc97b1c2d09c388e2bc60b70e5156 100644 (file)
@@ -183,7 +183,7 @@ void amdgpu_eviction_fence_destroy(struct amdgpu_eviction_fence_mgr *evf_mgr)
        dma_fence_wait(&ev_fence->base, false);
 
        /* Last unref of ev_fence */
-       dma_fence_put(&evf_mgr->ev_fence->base);
+       dma_fence_put(&ev_fence->base);
 }
 
 int amdgpu_eviction_fence_attach(struct amdgpu_eviction_fence_mgr *evf_mgr,