* [PATCH v2 0/2] clk: imx: imx6q: Fix device node reference leaks
@ 2026-01-31 8:11 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 8:11 ` [PATCH v2 2/2] clk: imx: imx6q: Fix device node reference leak in of_assigned_ldb_sels() Felix Gu
0 siblings, 2 replies; 7+ messages in thread
From: Felix Gu @ 2026-01-31 8:11 UTC (permalink / raw)
To: Abel Vesa, Peng Fan, Michael Turquette, Stephen Boyd, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Lucas Stach,
Philipp Zabel, Akshay Bhat, Ranjani Vaidyanathan, Shawn Guo
Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Felix Gu
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
Changes in v2:
- Fix device node reference leak in of_assigned_ldb_sels()
- Link to v1: https://lore.kernel.org/r/20260130-clk-imx6q-v1-1-2fa4da5dab85@gmail.com
---
Felix Gu (2):
clk: imx: imx6q: Fix device node reference leak in pll6_bypassed()
clk: imx: imx6q: Fix device node reference leak in of_assigned_ldb_sels()
drivers/clk/imx/clk-imx6q.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
base-commit: 33a647c659ffa5bdb94abc345c8c86768ff96215
change-id: 20260130-clk-imx6q-9c4b8835fc26
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 1/2] clk: imx: imx6q: Fix device node reference leak in pll6_bypassed() 2026-01-31 8:11 [PATCH v2 0/2] clk: imx: imx6q: Fix device node reference leaks Felix Gu @ 2026-01-31 8:11 ` Felix Gu 2026-01-31 16:16 ` Frank Li 2026-01-31 8:11 ` [PATCH v2 2/2] clk: imx: imx6q: Fix device node reference leak in of_assigned_ldb_sels() Felix Gu 1 sibling, 1 reply; 7+ messages in thread From: Felix Gu @ 2026-01-31 8:11 UTC (permalink / raw) To: Abel Vesa, Peng Fan, Michael Turquette, Stephen Boyd, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Lucas Stach, Philipp Zabel, Akshay Bhat, Ranjani Vaidyanathan, Shawn Guo Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Felix Gu 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; 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); + of_node_put(clkspec.np); if (clkspec.args[0] != IMX6QDL_CLK_PLL6) return true; -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] clk: imx: imx6q: Fix device node reference leak in pll6_bypassed() 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 0 siblings, 2 replies; 7+ messages in thread From: Frank Li @ 2026-01-31 16:16 UTC (permalink / raw) To: Felix Gu Cc: Abel Vesa, Peng Fan, Michael Turquette, Stephen Boyd, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Lucas Stach, Philipp Zabel, Akshay Bhat, Ranjani Vaidyanathan, Shawn Guo, linux-clk, imx, linux-arm-kernel, linux-kernel 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; > > 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. Frank > + of_node_put(clkspec.np); > if (clkspec.args[0] != IMX6QDL_CLK_PLL6) > return true; > > > -- > 2.43.0 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] clk: imx: imx6q: Fix device node reference leak in pll6_bypassed() 2026-01-31 16:16 ` Frank Li @ 2026-01-31 18:01 ` Felix Gu 2026-02-02 2:04 ` Peng Fan 1 sibling, 0 replies; 7+ messages in thread From: Felix Gu @ 2026-01-31 18:01 UTC (permalink / raw) To: Frank Li Cc: Abel Vesa, Peng Fan, Michael Turquette, Stephen Boyd, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Lucas Stach, Philipp Zabel, Akshay Bhat, Ranjani Vaidyanathan, Shawn Guo, linux-clk, imx, linux-arm-kernel, linux-kernel On Sun, Feb 1, 2026 at 12:17 AM Frank Li <Frank.li@nxp.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@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; > > > > 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] clk: imx: imx6q: Fix device node reference leak in pll6_bypassed() 2026-01-31 16:16 ` Frank Li 2026-01-31 18:01 ` Felix Gu @ 2026-02-02 2:04 ` Peng Fan 2026-02-02 14:17 ` Felix Gu 1 sibling, 1 reply; 7+ messages in thread From: Peng Fan @ 2026-02-02 2:04 UTC (permalink / raw) To: Frank Li, Felix Gu Cc: Felix Gu, Abel Vesa, Peng Fan, Michael Turquette, Stephen Boyd, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Lucas Stach, Philipp Zabel, Akshay Bhat, Ranjani Vaidyanathan, Shawn Guo, linux-clk, imx, linux-arm-kernel, linux-kernel 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 >> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] clk: imx: imx6q: Fix device node reference leak in pll6_bypassed() 2026-02-02 2:04 ` Peng Fan @ 2026-02-02 14:17 ` Felix Gu 0 siblings, 0 replies; 7+ messages in thread From: Felix Gu @ 2026-02-02 14:17 UTC (permalink / raw) To: Peng Fan Cc: Frank Li, Abel Vesa, Peng Fan, Michael Turquette, Stephen Boyd, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Lucas Stach, Philipp Zabel, Akshay Bhat, Ranjani Vaidyanathan, Shawn Guo, linux-clk, imx, linux-arm-kernel, linux-kernel On Mon, Feb 2, 2026 at 10:03 AM Peng Fan <peng.fan@oss.nxp.com> wrote: > > 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. Hi Peng, Thanks for your review. Frank also mentioned this in V1, but I think it may not be good to use clkspec.np after calling of_node_put(). Best regards, Felix Gu > > >> 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 > >> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] clk: imx: imx6q: Fix device node reference leak in of_assigned_ldb_sels() 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 8:11 ` Felix Gu 1 sibling, 0 replies; 7+ messages in thread From: Felix Gu @ 2026-01-31 8:11 UTC (permalink / raw) To: Abel Vesa, Peng Fan, Michael Turquette, Stephen Boyd, Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Lucas Stach, Philipp Zabel, Akshay Bhat, Ranjani Vaidyanathan, Shawn Guo Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Felix Gu The function of_assigned_ldb_sels() 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: 5d283b083800 ("clk: imx6: Fix procedure to switch the parent of LDB_DI_CLK") Signed-off-by: Felix Gu <ustc.gu@gmail.com> --- drivers/clk/imx/clk-imx6q.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c index 1d8e8f0891a3..58882dbc3a11 100644 --- a/drivers/clk/imx/clk-imx6q.c +++ b/drivers/clk/imx/clk-imx6q.c @@ -188,9 +188,11 @@ static void of_assigned_ldb_sels(struct device_node *node, } if (clkspec.np != node || clkspec.args[0] >= IMX6QDL_CLK_END) { pr_err("ccm: parent clock %d not in ccm\n", index); + of_node_put(clkspec.np); return; } parent = clkspec.args[0]; + of_node_put(clkspec.np); rc = of_parse_phandle_with_args(node, "assigned-clocks", "#clock-cells", index, &clkspec); @@ -198,9 +200,11 @@ static void of_assigned_ldb_sels(struct device_node *node, return; if (clkspec.np != node || clkspec.args[0] >= IMX6QDL_CLK_END) { pr_err("ccm: child clock %d not in ccm\n", index); + of_node_put(clkspec.np); return; } child = clkspec.args[0]; + of_node_put(clkspec.np); if (child != IMX6QDL_CLK_LDB_DI0_SEL && child != IMX6QDL_CLK_LDB_DI1_SEL) -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-02-02 14:17 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox