Skip to contentSkip to conversation

drm/amdgpu: fix resource leak in RAS error query on mode check failure

PATCH New David Baum 1 participant 1 message Mar 28

Subsystems (2)
lore
Share & tools
lore

David Baum

author
#0 lore raw

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.

---
 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
index c0336ca9b..3c7ac9c13 100644
@@ -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)