public inbox for amd-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: fix resource leak in RAS error query on mode check failure
@ 2026-03-27 23:40 David Baum
  0 siblings, 0 replies; only message in thread
From: David Baum @ 2026-03-27 23:40 UTC (permalink / raw)
  To: alexdeucher, christian.koenig, lijo.lazar; +Cc: amd-gfx, dri-devel, David Baum

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 <davidbaum461@gmail.com>
---
 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)


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-03-28 10:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 23:40 [PATCH] drm/amdgpu: fix resource leak in RAS error query on mode check failure David Baum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox