From: Peng Fan <peng.fan@oss.nxp.com>
To: Frank Li <Frank.li@nxp.com>, Felix Gu <ustc.gu@gmail.com>
Cc: Felix Gu <ustc.gu@gmail.com>, Abel Vesa <abelvesa@kernel.org>,
Peng Fan <peng.fan@nxp.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Lucas Stach <l.stach@pengutronix.de>,
Philipp Zabel <p.zabel@pengutronix.de>,
Akshay Bhat <akshay.bhat@timesys.com>,
Ranjani Vaidyanathan <Ranjani.Vaidyanathan@nxp.com>,
Shawn Guo <shawnguo@kernel.org>,
linux-clk@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] clk: imx: imx6q: Fix device node reference leak in pll6_bypassed()
Date: Mon, 2 Feb 2026 10:04:32 +0800 [thread overview]
Message-ID: <aYAGMAE7ppXP/lbR@shlinux89> (raw)
In-Reply-To: <aX4q+W3Sjx5SRHrC@lizhi-Precision-Tower-5810>
On Sat, Jan 31, 2026 at 11:16:57AM -0500, Frank Li wrote:
>On Sat, Jan 31, 2026 at 04:11:34PM +0800, Felix Gu wrote:
>> The function pll6_bypassed() calls of_parse_phandle_with_args()
>> but never calls of_node_put() to release the reference, causing
>> a memory leak.
>>
>> Fix this by adding proper cleanup calls on all exit paths.
>>
>> Fixes: 3cc48976e9763 ("clk: imx6q: handle ENET PLL bypass")
>> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
>> ---
>> drivers/clk/imx/clk-imx6q.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c
>> index bf4c1d9c9928..1d8e8f0891a3 100644
>> --- a/drivers/clk/imx/clk-imx6q.c
>> +++ b/drivers/clk/imx/clk-imx6q.c
>> @@ -238,8 +238,11 @@ static bool pll6_bypassed(struct device_node *node)
>> return false;
>>
One more comment:
Put one line here, "of_node_put", no need duplicate it in below.
>> if (clkspec.np == node &&
>> - clkspec.args[0] == IMX6QDL_PLL6_BYPASS)
>> + clkspec.args[0] == IMX6QDL_PLL6_BYPASS) {
>> + of_node_put(clkspec.np);
Drop this change
>> break;
>> + }
>> + of_node_put(clkspec.np);
Ditto.
Regards,
Peng
>> }
>>
>> /* PLL6 bypass is not part of the assigned clock list */
>> @@ -249,6 +252,7 @@ static bool pll6_bypassed(struct device_node *node)
>> ret = of_parse_phandle_with_args(node, "assigned-clock-parents",
>> "#clock-cells", index, &clkspec);
>>
>
>If ret is err, clkspec will not touched. So clkspec.np keep old value,
>of_node_put(clkspec.np) will put twice for previous np.
>
>So need add if (ret) check here. Or use difference variable clkspec with
>init 0.
>
>Frank
>
>> + of_node_put(clkspec.np);
>> if (clkspec.args[0] != IMX6QDL_CLK_PLL6)
>> return true;
>>
>>
>> --
>> 2.43.0
>>
next prev parent reply other threads:[~2026-02-02 2:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 8:11 [PATCH v2 0/2] clk: imx: imx6q: Fix device node reference leaks Felix Gu
2026-01-31 8:11 ` [PATCH v2 1/2] clk: imx: imx6q: Fix device node reference leak in pll6_bypassed() Felix Gu
2026-01-31 16:16 ` Frank Li
2026-01-31 18:01 ` Felix Gu
2026-02-02 2:04 ` Peng Fan [this message]
2026-02-02 14:17 ` Felix Gu
2026-01-31 8:11 ` [PATCH v2 2/2] clk: imx: imx6q: Fix device node reference leak in of_assigned_ldb_sels() Felix Gu
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=aYAGMAE7ppXP/lbR@shlinux89 \
--to=peng.fan@oss.nxp.com \
--cc=Frank.li@nxp.com \
--cc=Ranjani.Vaidyanathan@nxp.com \
--cc=abelvesa@kernel.org \
--cc=akshay.bhat@timesys.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=l.stach@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
--cc=ustc.gu@gmail.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