amdgpu_ras_query_error_status_with_event() calls
amdgpu_ras_error_data_init(&err_data) to allocate error data resources,
but when the subsequent amdgpu_ras_get_error_query_mode() call fails,
the function returns -EINVAL directly without calling
amdgpu_ras_error_data_fini() to release those resources.

Fix this by setting the return value and jumping to the existing
out_fini_err_data cleanup label, which is already used by the other
error paths in this function.

Signed-off-by: David Baum <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index c0336ca9b..3c7ac9c13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -1515,8 +1515,10 @@ static int 
amdgpu_ras_query_error_status_with_event(struct amdgpu_device *adev,
        if (ret)
                return ret;
 
-       if (!amdgpu_ras_get_error_query_mode(adev, &error_query_mode))
-               return -EINVAL;
+       if (!amdgpu_ras_get_error_query_mode(adev, &error_query_mode)) {
+               ret = -EINVAL;
+               goto out_fini_err_data;
+       }
 
        memset(&qctx, 0, sizeof(qctx));
        qctx.evid.type = type;
-- 
2.50.1 (Apple Git-155)

Reply via email to