All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Fix potential stale ACP domain on initialization failure
@ 2026-12-02 11:28 Guangshuo Li
  0 siblings, 0 replies; only message in thread
From: Guangshuo Li @ 2026-12-02 11:28 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, airlied, simona
  Cc: navid.emamdoost, amd-gfx, dri-devel

The ACP initialization error paths free acp_genpd without removing its
generic power domain. The global domain list can then reference freed
storage.

Remove the initialized domain before freeing it, and handle domain
initialization failure without attempting to remove an unregistered
domain.

This issue was found by our static analysis tool under development.

Fixes: 57be09c6e874 ("drm/amdgpu: fix multiple memory leaks in acp_hw_init")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
index f7dc385e6582..da3e249f40c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
@@ -254,7 +254,9 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block)
 	adev->acp.acp_genpd->gpd.power_on = acp_poweron;
 	adev->acp.acp_genpd->adev = adev;
 
-	pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false);
+	r = pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false);
+	if (r)
+		goto free_genpd;
 	dmi_check_system(acp_quirk_table);
 	switch (acp_machine_id) {
 	case ST_JADEITE:
@@ -498,6 +500,8 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block)
 	kfree(adev->acp.i2s_pdata);
 	kfree(adev->acp.acp_res);
 	kfree(adev->acp.acp_cell);
+	pm_genpd_remove(&adev->acp.acp_genpd->gpd);
+free_genpd:
 	kfree(adev->acp.acp_genpd);
 	return r;
 }

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244

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

only message in thread, other threads:[~2026-12-02 11:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 11:28 [PATCH] drm/amdgpu: Fix potential stale ACP domain on initialization failure Guangshuo Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.