* [PATCH] drm/radeon/sumo: Avoid UAF/double-free on power table parse errors
@ 2026-01-08 18:48 Kery Qi
0 siblings, 0 replies; only message in thread
From: Kery Qi @ 2026-01-08 18:48 UTC (permalink / raw)
To: christian.koenig; +Cc: netdev, Kery Qi
sumo_parse_power_table() allocates rdev->pm.dpm.ps and then allocates a
per-state sumo_ps (ps_priv) for each entry. On error, it currently frees
rdev->pm.dpm.ps in two places:
- if (!rdev->pm.power_state[i].clock_info) { kfree(rdev->pm.dpm.ps); ... }
- if (ps == NULL) { kfree(rdev->pm.dpm.ps); ... }
However, when sumo_parse_power_table() fails during the load/init path,
the driver later unwinds and calls the corresponding fini path, which
dereferences rdev->pm.dpm.ps[i].ps_priv and then frees rdev->pm.dpm.ps.
Freeing rdev->pm.dpm.ps inside sumo_parse_power_table() leaves a dangling
pointer that the unwind/fini path will both dereference and free again,
resulting in a use-after-free and a double-free.
Fix this by removing the local kfree(rdev->pm.dpm.ps) from the error
returns in sumo_parse_power_table() and letting the common unwind/fini
path perform the cleanup.
Fixes: 80ea2c129c76 ("drm/radeon/kms: add dpm support for sumo asics (v2)")
Signed-off-by: Kery Qi <qikeyu2017@gmail.com>
---
drivers/gpu/drm/radeon/sumo_dpm.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c
index b11f7c5bbcbe..af649b7b2e1a 100644
--- a/drivers/gpu/drm/radeon/sumo_dpm.c
+++ b/drivers/gpu/drm/radeon/sumo_dpm.c
@@ -1491,15 +1491,11 @@ static int sumo_parse_power_table(struct radeon_device *rdev)
non_clock_array_index = power_state->v2.nonClockInfoIndex;
non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
&non_clock_info_array->nonClockInfo[non_clock_array_index];
- if (!rdev->pm.power_state[i].clock_info) {
- kfree(rdev->pm.dpm.ps);
+ if (!rdev->pm.power_state[i].clock_info)
return -EINVAL;
- }
ps = kzalloc(sizeof(struct sumo_ps), GFP_KERNEL);
- if (ps == NULL) {
- kfree(rdev->pm.dpm.ps);
+ if (ps == NULL)
return -ENOMEM;
- }
rdev->pm.dpm.ps[i].ps_priv = ps;
k = 0;
idx = (u8 *)&power_state->v2.clockInfoIndex[0];
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-08 18:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 18:48 [PATCH] drm/radeon/sumo: Avoid UAF/double-free on power table parse errors Kery Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox