mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-17 03:07:53 -05:00
pmdomain: core: Reset genpd->states to avoid freeing invalid data
If genpd_alloc_data() allocates data for the default power-states for the genpd, let's make sure to also reset the pointer in the error path. This makes sure a genpd provider driver doesn't end up trying to free the data again, but using an invalid pointer. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Dhruva Gole <d-gole@ti.com> Link: https://lore.kernel.org/r/20250402120613.1116711-1-ulf.hansson@linaro.org
This commit is contained in:
@@ -2287,8 +2287,10 @@ static int genpd_alloc_data(struct generic_pm_domain *genpd)
|
||||
return 0;
|
||||
put:
|
||||
put_device(&genpd->dev);
|
||||
if (genpd->free_states == genpd_free_default_power_state)
|
||||
if (genpd->free_states == genpd_free_default_power_state) {
|
||||
kfree(genpd->states);
|
||||
genpd->states = NULL;
|
||||
}
|
||||
free:
|
||||
if (genpd_is_cpu_domain(genpd))
|
||||
free_cpumask_var(genpd->cpus);
|
||||
|
||||
Reference in New Issue
Block a user