* [PATCH] cpufreq: Avoid a bad reference count on CPU node
@ 2024-09-17 13:42 Miquel Sabaté Solà
2024-10-01 5:27 ` Miquel Sabaté Solà
2024-10-01 6:32 ` Viresh Kumar
0 siblings, 2 replies; 5+ messages in thread
From: Miquel Sabaté Solà @ 2024-09-17 13:42 UTC (permalink / raw)
To: rafael; +Cc: viresh.kumar, linux-pm, linux-kernel,
Miquel Sabaté Solà
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>
---
include/linux/cpufreq.h | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index d4d2f4d1d7cb..aabec598f79a 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -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;
}
--
2.46.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] cpufreq: Avoid a bad reference count on CPU node
2024-09-17 13:42 [PATCH] cpufreq: Avoid a bad reference count on CPU node Miquel Sabaté Solà
@ 2024-10-01 5:27 ` Miquel Sabaté Solà
2024-10-01 6:32 ` Viresh Kumar
1 sibling, 0 replies; 5+ messages in thread
From: Miquel Sabaté Solà @ 2024-10-01 5:27 UTC (permalink / raw)
To: rafael; +Cc: viresh.kumar, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1416 bytes --]
On dt., de set. 17 2024, Miquel Sabaté Solà wrote:
> 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>
> ---
> include/linux/cpufreq.h | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index d4d2f4d1d7cb..aabec598f79a 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -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;
> }
Gently ping :)
Do you have some time to take a look at this fix?
Thanks,
Miquel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cpufreq: Avoid a bad reference count on CPU node
2024-09-17 13:42 [PATCH] cpufreq: Avoid a bad reference count on CPU node Miquel Sabaté Solà
2024-10-01 5:27 ` Miquel Sabaté Solà
@ 2024-10-01 6:32 ` Viresh Kumar
2024-10-01 18:46 ` Rafael J. Wysocki
1 sibling, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2024-10-01 6:32 UTC (permalink / raw)
To: Miquel Sabaté Solà; +Cc: rafael, linux-pm, linux-kernel
On 17-09-24, 15:42, Miquel Sabaté Solà wrote:
> 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>
> ---
> include/linux/cpufreq.h | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index d4d2f4d1d7cb..aabec598f79a 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -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;
> }
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cpufreq: Avoid a bad reference count on CPU node
2024-10-01 6:32 ` Viresh Kumar
@ 2024-10-01 18:46 ` Rafael J. Wysocki
2024-10-01 19:35 ` Miquel Sabaté Solà
0 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2024-10-01 18:46 UTC (permalink / raw)
To: Viresh Kumar, Miquel Sabaté Solà; +Cc: linux-pm, linux-kernel
On Tue, Oct 1, 2024 at 8:32 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 17-09-24, 15:42, Miquel Sabaté Solà wrote:
> > 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>
> > ---
> > include/linux/cpufreq.h | 6 +-----
> > 1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> > index d4d2f4d1d7cb..aabec598f79a 100644
> > --- a/include/linux/cpufreq.h
> > +++ b/include/linux/cpufreq.h
> > @@ -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;
> > }
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> --
Applied as 6.12-rc material, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cpufreq: Avoid a bad reference count on CPU node
2024-10-01 18:46 ` Rafael J. Wysocki
@ 2024-10-01 19:35 ` Miquel Sabaté Solà
0 siblings, 0 replies; 5+ messages in thread
From: Miquel Sabaté Solà @ 2024-10-01 19:35 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Viresh Kumar, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1837 bytes --]
On dt., d’oct. 01 2024, Rafael J. Wysocki wrote:
> On Tue, Oct 1, 2024 at 8:32 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>>
>> On 17-09-24, 15:42, Miquel Sabaté Solà wrote:
>> > 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>
>> > ---
>> > include/linux/cpufreq.h | 6 +-----
>> > 1 file changed, 1 insertion(+), 5 deletions(-)
>> >
>> > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
>> > index d4d2f4d1d7cb..aabec598f79a 100644
>> > --- a/include/linux/cpufreq.h
>> > +++ b/include/linux/cpufreq.h
>> > @@ -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;
>> > }
>>
>> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
>>
>> --
>
> Applied as 6.12-rc material, thanks!
Great, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-01 19:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-17 13:42 [PATCH] cpufreq: Avoid a bad reference count on CPU node Miquel Sabaté Solà
2024-10-01 5:27 ` Miquel Sabaté Solà
2024-10-01 6:32 ` Viresh Kumar
2024-10-01 18:46 ` Rafael J. Wysocki
2024-10-01 19:35 ` Miquel Sabaté Solà
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox