From: Stephen Boyd <sboyd@kernel.org>
To: kristo@kernel.org, linux-clk@vger.kernel.org,
linux-omap@vger.kernel.org, mturquette@baylibre.com,
windhl@126.com
Subject: Re: [PATCH] clk: ti: Call of_node_get() before of_find_xxx() API
Date: Fri, 30 Sep 2022 17:11:43 -0700 [thread overview]
Message-ID: <20221001001145.7E746C433D6@smtp.kernel.org> (raw)
In-Reply-To: <20220915031121.4003589-1-windhl@126.com>
Quoting Liang He (2022-09-14 20:11:21)
> In ti_find_clock_provider(), we need to call of_node_get() for
> of_find_node_by_name() which will automatically call of_node_put()
> for the 'from' argument.
>
> Fixes: 51f661ef9a10 ("clk: ti: Add ti_find_clock_provider() to use clock-output-names")
> Signed-off-by: Liang He <windhl@126.com>
> ---
> drivers/clk/ti/clk.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
> index 373e9438b57a..7c390cd67e1a 100644
> --- a/drivers/clk/ti/clk.c
> +++ b/drivers/clk/ti/clk.c
> @@ -147,6 +147,7 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
> return np;
>
> /* Fall back to using old node name base provider name */
> + of_node_get(from);
It seems better to hold the reference from the earlier search.
> return of_find_node_by_name(from, name);
> }
How about this?
----8<----
diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index ef2a445c63a3..a99279265e40 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -139,11 +139,12 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
break;
}
}
- of_node_put(from);
kfree(tmp);
- if (found)
+ if (found) {
+ of_node_put(from);
return np;
+ }
/* Fall back to using old node name base provider name */
return of_find_node_by_name(from, name);
prev parent reply other threads:[~2022-10-01 0:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 3:11 [PATCH] clk: ti: Call of_node_get() before of_find_xxx() API Liang He
2022-10-01 0:11 ` Stephen Boyd [this message]
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=20221001001145.7E746C433D6@smtp.kernel.org \
--to=sboyd@kernel.org \
--cc=kristo@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=windhl@126.com \
/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;
as well as URLs for NNTP newsgroup(s).