blob: 9c7ac25e44fb20c323d42eb7f68fc7162181cf32 [file]
From lanbincn@139.com Tue Mar 24 09:22:43 2026
From: Bin Lan <lanbincn@139.com>
Date: Tue, 24 Mar 2026 16:21:13 +0800
Subject: cpufreq: Avoid a bad reference count on CPU node
To: gregkh@linuxfoundation.org, stable@vger.kernel.org
Cc: linux-pm@vger.kernel.org, "Miquel Sabaté Solà" <mikisabate@gmail.com>, "Viresh Kumar" <viresh.kumar@linaro.org>, "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>, "Bin Lan" <lanbincn@139.com>
Message-ID: <20260324082113.6275-2-lanbincn@139.com>
From: Miquel Sabaté Solà <mikisabate@gmail.com>
[ Upstream commit c0f02536fffbbec71aced36d52a765f8c4493dc2 ]
In the parse_perf_domain function, if the call to
of_parse_phandle_with_args returns an error, then the reference to the
CPU device node that was acquired at the start of the function would not
be properly decremented.
Address this by declaring the variable with the __free(device_node)
cleanup attribute.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://patch.msgid.link/20240917134246.584026-1-mikisabate@gmail.com
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ Minor context conflict resolved. ]
Signed-off-by: Bin Lan <lanbincn@139.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/cpufreq.h | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -1014,11 +1014,10 @@ static inline int cpufreq_table_count_va
static inline int parse_perf_domain(int cpu, const char *list_name,
const char *cell_name)
{
- struct device_node *cpu_np;
struct of_phandle_args args;
int ret;
- cpu_np = of_cpu_device_node_get(cpu);
+ struct device_node *cpu_np __free(device_node) = of_cpu_device_node_get(cpu);
if (!cpu_np)
return -ENODEV;
@@ -1027,8 +1026,6 @@ static inline int parse_perf_domain(int
if (ret < 0)
return ret;
- of_node_put(cpu_np);
-
return args.args[0];
}