[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAN4SLj0D2PV9vFW4=dAF3ypAtA8JvhJpEut8Aumsx4JaMSEsiw@mail.gmail.com>
Date: Sun, 1 Feb 2026 02:01:11 +0800
From: Felix Gu <ustc.gu@...il.com>
To: Frank Li <Frank.li@....com>
Cc: Abel Vesa <abelvesa@...nel.org>, Peng Fan <peng.fan@....com>,
Michael Turquette <mturquette@...libre.com>, Stephen Boyd <sboyd@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>, Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Lucas Stach <l.stach@...gutronix.de>,
Philipp Zabel <p.zabel@...gutronix.de>, Akshay Bhat <akshay.bhat@...esys.com>,
Ranjani Vaidyanathan <Ranjani.Vaidyanathan@....com>, Shawn Guo <shawnguo@...nel.org>,
linux-clk@...r.kernel.org, imx@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] clk: imx: imx6q: Fix device node reference leak in pll6_bypassed()
On Sun, Feb 1, 2026 at 12:17 AM Frank Li <Frank.li@....com> 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@...il.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;
> >
> > if (clkspec.np == node &&
> > - clkspec.args[0] == IMX6QDL_PLL6_BYPASS)
> > + clkspec.args[0] == IMX6QDL_PLL6_BYPASS) {
> > + of_node_put(clkspec.np);
> > break;
> > + }
> > + of_node_put(clkspec.np);
> > }
> >
> > /* 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.
Thanks, I will fix it in v3.
>
> Frank
>
> > + of_node_put(clkspec.np);
> > if (clkspec.args[0] != IMX6QDL_CLK_PLL6)
> > return true;
> >
> >
> > --
> > 2.43.0
> >
Best regards,
Felix Gu
Powered by blists - more mailing lists