"aca_handle_is_valid()" used inverted list-membership logic. It returned false when "!list_empty(&handle->node)" was true, even though a non-empty node indicates that the handle is currently registered. As a result, registered handles were incorrectly considered invalid.
Fix "aca_handle_is_valid()" to verify that the handle is non-NULL, has a valid mask, and is currently registered in the handle list. Update "amdgpu_aca_get_error_data()" to reject invalid handles and return 0 rather than "-EOPNOTSUPP". This allows global RAS queries to safely skip non-ACA blocks without treating an unsupported block as an error. Additionally, use "list_del_init()" in "remove_aca_handle()" before "aca_fini_error_cache()". Unlike "list_del()", which poisons the removed node's pointers, "list_del_init()" reinitializes the node as an empty list. This ensures that "aca_handle_is_valid()" recognizes the handle as unregistered before its error cache is destroyed. Signed-off-by: Sreeraj S Kurup <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c index c76664af9902..d48f2c4d6c84 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c @@ -586,10 +586,7 @@ static int __aca_get_error_data(struct amdgpu_device *adev, struct aca_handle *h static bool aca_handle_is_valid(struct aca_handle *handle) { - if (!handle->mask || !list_empty(&handle->node)) - return false; - - return true; + return handle && handle->mask && !list_empty(&handle->node); } int amdgpu_aca_get_error_data(struct amdgpu_device *adev, struct aca_handle *handle, @@ -599,8 +596,8 @@ int amdgpu_aca_get_error_data(struct amdgpu_device *adev, struct aca_handle *han if (!handle || !err_data) return -EINVAL; - if (aca_handle_is_valid(handle)) - return -EOPNOTSUPP; + if (!aca_handle_is_valid(handle)) + return 0; if ((type < 0) || (!(BIT(type) & handle->mask))) return 0; @@ -716,9 +713,10 @@ static void remove_aca_handle(struct aca_handle *handle) { struct aca_handle_manager *mgr = handle->mgr; - aca_fini_error_cache(handle); - list_del(&handle->node); + list_del_init(&handle->node); mgr->nr_handles--; + aca_fini_error_cache(handle); + } static void remove_aca_sysfs(struct aca_handle *handle) -- 2.54.0
