[PATCH v3 12/12] PM: EM: Use scope-based cleanup helper
Krzysztof Kozlowski
krzk at kernel.org
Wed Sep 3 01:57:22 AEST 2025
On 01/09/2025 10:57, Zihuan Zhang wrote:
> Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy)
> annotation for policy references. This reduces the risk of reference
> counting mistakes and aligns the code with the latest kernel style.
>
> No functional change intended.
>
> Signed-off-by: Zihuan Zhang <zhangzihuan at kylinos.cn>
> ---
> kernel/power/energy_model.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> index ea7995a25780..852d48039ce2 100644
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -451,7 +451,7 @@ static void
> em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table)
> {
> struct em_perf_domain *pd = dev->em_pd;
> - struct cpufreq_policy *policy;
> + struct cpufreq_policy *policy __free(put_cpufreq_policy);
You are not improving the source code here. This is not how to use
__free() and you clearly do not understand the source code.
What's more, you did not use standard tools which would tell you this is
buggy and wrong.
Don't introduce cleanup.h if you do not understand how it works.
Best regards,
Krzysztof
More information about the Linuxppc-dev
mailing list