drm/amdgpu: fix resource leak in RAS error query on mode check failure
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix resource leak in RAS error query on mode check failure
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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -2
@@ -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;
Signature · 1 line
2.50.1 (Apple Git-155)