* [PATCH] cpufreq: ti: Implement scope-based cleanup in ti_cpufreq_match_node()
@ 2024-04-23 2:07 Shivani Gupta
2024-04-23 7:11 ` Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Shivani Gupta @ 2024-04-23 2:07 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar
Cc: linux-pm, linux-kernel, skhan, javier.carrasco.cruz,
Shivani Gupta, Julia Lawall
This patch modifies the ti_cpufreq_match_node() function to utilize the
__free() cleanup handler for automatically releasing the device
node when it goes out of scope.
By moving the declaration to the initialization, the patch ensures that
the device node is properly managed throughout the function's scope,
thus eliminating the need for manual invocation of of_node_put().
This approach reduces the potential for memory leaks.
Suggested-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Shivani Gupta <shivani07g@gmail.com>
---
drivers/cpufreq/ti-cpufreq.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
index 46c41e2ca727..714ed53753fa 100644
--- a/drivers/cpufreq/ti-cpufreq.c
+++ b/drivers/cpufreq/ti-cpufreq.c
@@ -347,12 +347,10 @@ static const struct of_device_id ti_cpufreq_of_match[] = {
static const struct of_device_id *ti_cpufreq_match_node(void)
{
- struct device_node *np;
+ struct device_node *np __free(device_node) = of_find_node_by_path("/");
const struct of_device_id *match;
- np = of_find_node_by_path("/");
match = of_match_node(ti_cpufreq_of_match, np);
- of_node_put(np);
return match;
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: ti: Implement scope-based cleanup in ti_cpufreq_match_node()
2024-04-23 2:07 [PATCH] cpufreq: ti: Implement scope-based cleanup in ti_cpufreq_match_node() Shivani Gupta
@ 2024-04-23 7:11 ` Julia Lawall
2024-04-23 7:22 ` Viresh Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2024-04-23 7:11 UTC (permalink / raw)
To: Shivani Gupta
Cc: Rafael J . Wysocki, Viresh Kumar, linux-pm, linux-kernel, skhan,
javier.carrasco.cruz
On Tue, 23 Apr 2024, Shivani Gupta wrote:
> This patch modifies the ti_cpufreq_match_node() function to utilize the
> __free() cleanup handler for automatically releasing the device
> node when it goes out of scope.
>
> By moving the declaration to the initialization, the patch ensures that
> the device node is properly managed throughout the function's scope,
> thus eliminating the need for manual invocation of of_node_put().
> This approach reduces the potential for memory leaks.
The code is fine. The log message is a bit verbose. Try to avoid
referring to the patch. It's obvious that you are talking about the
patch. Try to favor the imperative, so "Modify..." instead of "This patch
modifies".
julia
>
> Suggested-by: Julia Lawall <julia.lawall@inria.fr>
> Signed-off-by: Shivani Gupta <shivani07g@gmail.com>
> ---
> drivers/cpufreq/ti-cpufreq.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
> index 46c41e2ca727..714ed53753fa 100644
> --- a/drivers/cpufreq/ti-cpufreq.c
> +++ b/drivers/cpufreq/ti-cpufreq.c
> @@ -347,12 +347,10 @@ static const struct of_device_id ti_cpufreq_of_match[] = {
>
> static const struct of_device_id *ti_cpufreq_match_node(void)
> {
> - struct device_node *np;
> + struct device_node *np __free(device_node) = of_find_node_by_path("/");
> const struct of_device_id *match;
>
> - np = of_find_node_by_path("/");
> match = of_match_node(ti_cpufreq_of_match, np);
> - of_node_put(np);
>
> return match;
> }
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: ti: Implement scope-based cleanup in ti_cpufreq_match_node()
2024-04-23 7:11 ` Julia Lawall
@ 2024-04-23 7:22 ` Viresh Kumar
0 siblings, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2024-04-23 7:22 UTC (permalink / raw)
To: Julia Lawall
Cc: Shivani Gupta, Rafael J . Wysocki, linux-pm, linux-kernel, skhan,
javier.carrasco.cruz
On 23-04-24, 09:11, Julia Lawall wrote:
>
>
> On Tue, 23 Apr 2024, Shivani Gupta wrote:
>
> > This patch modifies the ti_cpufreq_match_node() function to utilize the
> > __free() cleanup handler for automatically releasing the device
> > node when it goes out of scope.
> >
> > By moving the declaration to the initialization, the patch ensures that
> > the device node is properly managed throughout the function's scope,
> > thus eliminating the need for manual invocation of of_node_put().
> > This approach reduces the potential for memory leaks.
>
> The code is fine. The log message is a bit verbose. Try to avoid
> referring to the patch. It's obvious that you are talking about the
> patch. Try to favor the imperative, so "Modify..." instead of "This patch
> modifies".
Fixed while applying.
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-23 7:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 2:07 [PATCH] cpufreq: ti: Implement scope-based cleanup in ti_cpufreq_match_node() Shivani Gupta
2024-04-23 7:11 ` Julia Lawall
2024-04-23 7:22 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®