Skip to content

Commit 9901201

Browse files
committed
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 <[email protected]> Reviewed-by: Dhruva Gole <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0a8a888 commit 9901201

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/pmdomain/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2287,8 +2287,10 @@ static int genpd_alloc_data(struct generic_pm_domain *genpd)
22872287
return 0;
22882288
put:
22892289
put_device(&genpd->dev);
2290-
if (genpd->free_states == genpd_free_default_power_state)
2290+
if (genpd->free_states == genpd_free_default_power_state) {
22912291
kfree(genpd->states);
2292+
genpd->states = NULL;
2293+
}
22922294
free:
22932295
if (genpd_is_cpu_domain(genpd))
22942296
free_cpumask_var(genpd->cpus);

0 commit comments

Comments
 (0)