drm/amdgpu: fix userq resource double freed
authorPrike Liang <Prike.Liang@amd.com>
Mon, 12 May 2025 07:09:21 +0000 (15:09 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 14 May 2025 15:30:03 +0000 (11:30 -0400)
As the userq resource was already freed at the drm_release
early phase, it should avoid freeing userq resource again
at the later kms postclose callback.

Signed-off-by: Prike Liang <Prike.Liang@amd.com>
Reviewed-by: Jesse Zhang <Jesse.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

index ef8a22cf565ad285e55a9229e453e8e6591c97bc..9fbb04aee97bcd580146ec39abcda0b20eb1eee6 100644 (file)
@@ -1502,10 +1502,11 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
                amdgpu_bo_unreserve(pd);
        }
 
-       fpriv->evf_mgr.fd_closing = true;
-       amdgpu_userq_mgr_fini(&fpriv->userq_mgr);
-       amdgpu_eviction_fence_destroy(&fpriv->evf_mgr);
-
+       if (!fpriv->evf_mgr.fd_closing) {
+               fpriv->evf_mgr.fd_closing = true;
+               amdgpu_userq_mgr_fini(&fpriv->userq_mgr);
+               amdgpu_eviction_fence_destroy(&fpriv->evf_mgr);
+       }
        amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr);
        amdgpu_vm_fini(adev, &fpriv->vm);