[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <oitkhsra7pax76dnz7r2b6wrpcljck5mwjubrjqclrerpp2kif@alms5oodo5h4>
Date: Mon, 15 Dec 2025 10:54:14 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Miaoqian Lin <linmq006@...il.com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Madhavan Srinivasan <maddy@...ux.ibm.com>, Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin <npiggin@...il.com>, "Christophe Leroy (CS GROUP)" <chleroy@...nel.org>,
Sudeep Holla <sudeep.holla@....com>, Paul Mackerras <paulus@...abs.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>, linux-pm@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH] cpufreq: pmac64-cpufreq: Fix refcount leak on error paths
On 12-12-25, 13:29, Miaoqian Lin wrote:
> of_cpu_device_node_get obtain a reference to the device node which
> must be released with of_node_put().
>
> Add missing of_node_put() on error paths to fix.
>
> Found via static analysis and code review.
>
> Fixes: 760287ab90a3 ("cpufreq: pmac64-cpufreq: remove device tree parsing for cpu nodes")
> Fixes: 4350147a816b ("[PATCH] ppc64: SMU based macs cpufreq support")
> Cc: stable@...r.kernel.org
> Signed-off-by: Miaoqian Lin <linmq006@...il.com>
> ---
> drivers/cpufreq/pmac64-cpufreq.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
> index 80897ec8f00e..0e0205b888ba 100644
> --- a/drivers/cpufreq/pmac64-cpufreq.c
> +++ b/drivers/cpufreq/pmac64-cpufreq.c
> @@ -356,8 +356,10 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpunode)
> use_volts_smu = 1;
> else if (of_machine_is_compatible("PowerMac11,2"))
> use_volts_vdnap = 1;
> - else
> - return -ENODEV;
> + else {
> + rc = -ENODEV;
> + goto bail_noprops;
> + }
>
> /* Check 970FX for now */
> valp = of_get_property(cpunode, "cpu-version", NULL);
> @@ -430,8 +432,11 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpunode)
> * supporting anything else.
> */
> valp = of_get_property(cpunode, "clock-frequency", NULL);
> - if (!valp)
> - return -ENODEV;
> + if (!valp) {
> + rc = -ENODEV;
> + goto bail_noprops;
> + }
> +
> max_freq = (*valp)/1000;
> g5_cpu_freqs[0].frequency = max_freq;
> g5_cpu_freqs[1].frequency = max_freq/2;
I would rather handle this in the function that gets the reference of the node
in the first place: g5_cpufreq_init().
--
viresh
Powered by blists - more mailing lists