Re: [PATCH] cpuidle: dt_idle_genpd: kfree() the original name allocation

From: Ulf Hansson

Date: Tue Sep 01 2026 - 14:09:00 EST


On Fri, Aug 21, 2026 at 9:57 AM Linkai Gong <gonglinkai@xxxxxxxxxx> wrote:
>
> dt_idle_pd_alloc() kasprintf()s the full node path, then points
> pd->name at kbasename() of that string. dt_idle_pd_free() kfree()s
> pd->name, which is no longer the start of the allocation.
>
> Copy the basename instead.
>
> Fixes: 9d976d6721df ("cpuidle: Factor-out power domain related code from PSCI domain driver")
> Signed-off-by: Linkai Gong <gonglinkai@xxxxxxxxxx>

Applied for fixes and by adding a stable tag, thanks!

Kind regards
Uffe


> ---
> drivers/cpuidle/dt_idle_genpd.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/cpuidle/dt_idle_genpd.c b/drivers/cpuidle/dt_idle_genpd.c
> index d292975cc468..ed41a90eeeb7 100644
> --- a/drivers/cpuidle/dt_idle_genpd.c
> +++ b/drivers/cpuidle/dt_idle_genpd.c
> @@ -99,7 +99,7 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
> if (!pd)
> goto out;
>
> - pd->name = kasprintf(GFP_KERNEL, "%pOF", np);
> + pd->name = kstrdup(kbasename(of_node_full_name(np)), GFP_KERNEL);
> if (!pd->name)
> goto free_pd;
>
> @@ -112,7 +112,6 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
> goto free_name;
>
> pd->free_states = pd_free_states;
> - pd->name = kbasename(pd->name);
> pd->states = states;
> pd->state_count = state_count;
>
> --
> 2.25.1
>