From: Julia Lawall <julia.lawall@inria.fr>
To: Shivani Gupta <shivani07g@gmail.com>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com
Subject: Re: [PATCH] cpufreq: ti: Implement scope-based cleanup in ti_cpufreq_match_node()
Date: Tue, 23 Apr 2024 09:11:07 +0200 (CEST) [thread overview]
Message-ID: <aa2bd3b6-7bb9-98ae-b762-6060f828170@inria.fr> (raw)
In-Reply-To: <20240423020727.776360-1-shivani07g@gmail.com>
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
>
>
next prev parent reply other threads:[~2024-04-23 7:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 2:07 Shivani Gupta
2024-04-23 7:11 ` Julia Lawall [this message]
2024-04-23 7:22 ` Viresh Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa2bd3b6-7bb9-98ae-b762-6060f828170@inria.fr \
--to=julia.lawall@inria.fr \
--cc=javier.carrasco.cruz@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=shivani07g@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®