cpufreq: Avoid a bad reference count on CPU node
PATCH 1/1 cpufreq: Avoid a bad reference count on CPU node
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.
--- include/linux/cpufreq.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
include/linux/cpufreq.h +1 -5
@@ -1113,10 +1113,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 ;
@@ -1124,9 +1123,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 ; }
Signature · 1 line
2.46.0
Quoted 30 lines · Miquel Sabaté Solà
In the
parse_perf_domainfunction, if the call toof_parse_phandle_with_argsreturns 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à <[email protected]>--- include/linux/cpufreq.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)include/linux/cpufreq.h +1
-2@@ -1113,10 +1113,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 ;
include/linux/cpufreq.h static inline int parse_perf_domain(int cpu, const char *list_name, · line 1127
Quoted 8 lines
include/linux/cpufreq.h +0
-3@@ -1124,9 +1123,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 ; }
Gently ping :)
Do you have some time to take a look at this fix?
Thanks,
Miquel
Quoted 30 lines · Miquel Sabaté Solà
In the
parse_perf_domainfunction, if the call toof_parse_phandle_with_argsreturns 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à <[email protected]>--- include/linux/cpufreq.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)include/linux/cpufreq.h +1
-2@@ -1113,10 +1113,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 ;
include/linux/cpufreq.h static inline int parse_perf_domain(int cpu, const char *list_name, · line 1127
Quoted 8 lines
include/linux/cpufreq.h +0
-3@@ -1124,9 +1123,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 ; }
Signature · 1 line
viresh
Quoted 43 lines · Viresh Kumar
Quoted 30 lines · Miquel Sabaté Solà
In the
parse_perf_domainfunction, if the call toof_parse_phandle_with_argsreturns 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à <[email protected]>--- include/linux/cpufreq.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)include/linux/cpufreq.h +1
-2@@ -1113,10 +1113,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 ;include/linux/cpufreq.h static inline int parse_perf_domain(int cpu, const char *list_name, · line 1127
Quoted 8 lines
include/linux/cpufreq.h +0
-3@@ -1124,9 +1123,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 ; }Acked-by Viresh Kumar <[email protected]>
Quoted 1 line
--
Applied as 6.12-rc material, thanks!
Quoted 44 lines · Rafael J. Wysocki
Quoted 43 lines · Viresh Kumar
Quoted 30 lines · Miquel Sabaté Solà
In the
parse_perf_domainfunction, if the call toof_parse_phandle_with_argsreturns 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à <[email protected]>--- include/linux/cpufreq.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)include/linux/cpufreq.h +1
-2@@ -1113,10 +1113,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 ;include/linux/cpufreq.h static inline int parse_perf_domain(int cpu, const char *list_name, · line 1127
Quoted 8 lines
include/linux/cpufreq.h +0
-3@@ -1124,9 +1123,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 ; }Acked-by Viresh Kumar <[email protected]>
Quoted 3 lines
Quoted 1 line
--
Applied as 6.12-rc material, thanks!
Great, thanks!