This is a note to let you know that I've just added the patch titled cpufreq: Avoid a bad reference count on CPU node to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: cpufreq-avoid-a-bad-reference-count-on-cpu-node.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 060240fce282fe2fdb001451d0a5f6525c66835e Author: Miquel Sabaté Solà <mikisabate@xxxxxxxxx> Date: Tue Sep 17 15:42:46 2024 +0200 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@xxxxxxxxx> Acked-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx> Link: https://patch.msgid.link/20240917134246.584026-1-mikisabate@xxxxxxxxx Cc: All applicable <stable@xxxxxxxxxxxxxxx> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 1976244b97e3a..3759d0a15c7b2 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; }