summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-09-17 16:42:46 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-11-08 18:26:39 +0300
commit6c3d8387839252f1a0fc6367f314446e4a2ebd0b (patch)
treecd02804d8d3c22effb58d68e6ae6d15470feaf29 /include/linux
parent380bcd5aa80fa1507adb774b7d139f927286d553 (diff)
downloadlinux-6c3d8387839252f1a0fc6367f314446e4a2ebd0b.tar.xz
cpufreq: Avoid a bad reference count on CPU node
[ 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/cpufreq.h6
1 files changed, 1 insertions, 5 deletions
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 1976244b97e3..3759d0a15c7b 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -1126,10 +1126,9 @@ static inline int parse_perf_domain(int cpu, const char *list_name,
const char *cell_name,
struct of_phandle_args *args)
{
- struct device_node *cpu_np;
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;
@@ -1137,9 +1136,6 @@ static inline int parse_perf_domain(int cpu, const char *list_name,
args);
if (ret < 0)
return ret;
-
- of_node_put(cpu_np);
-
return 0;
}