The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] clk: tegra: tegra124-emc: put EMC node on register failure
@ 2026-07-08 11:20 Guangshuo Li
  2026-07-08 16:41 ` Brian Masney
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-07-08 11:20 UTC (permalink / raw)
  To: Prashant Gaikwad, Michael Turquette, Stephen Boyd, Brian Masney,
	Thierry Reding, Jonathan Hunter, Mikko Perttunen, Tomeu Vizoso,
	linux-clk, linux-tegra, linux-kernel
  Cc: Guangshuo Li

tegra124_clk_register_emc() stores a device node reference returned by
of_parse_phandle() in tegra->emc_node.

If clk_register() fails, the function returns an error before that
reference can be consumed and released by the normal runtime path. The
tegra_clk_emc object is freed on this failure path, but freeing the
object does not drop the OF node reference stored in it.

Drop the EMC node reference before freeing the tegra_clk_emc object.
of_node_put() is safe for a NULL node, so this also covers the case where
the phandle is absent.

Fixes: 2db04f16b589 ("clk: tegra: Add EMC clock driver")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/clk/tegra/clk-tegra124-emc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/tegra/clk-tegra124-emc.c b/drivers/clk/tegra/clk-tegra124-emc.c
index f3b2c96fdcfc..94ac24ea1e6a 100644
--- a/drivers/clk/tegra/clk-tegra124-emc.c
+++ b/drivers/clk/tegra/clk-tegra124-emc.c
@@ -537,6 +537,7 @@ struct clk *tegra124_clk_register_emc(void __iomem *base, struct device_node *np
 
 	clk = clk_register(NULL, &tegra->hw);
 	if (IS_ERR(clk)) {
+		of_node_put(tegra->emc_node);
 		kfree(tegra);
 		return clk;
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] clk: tegra: tegra124-emc: put EMC node on register failure
  2026-07-08 11:20 [PATCH] clk: tegra: tegra124-emc: put EMC node on register failure Guangshuo Li
@ 2026-07-08 16:41 ` Brian Masney
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Masney @ 2026-07-08 16:41 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: Prashant Gaikwad, Michael Turquette, Stephen Boyd, Thierry Reding,
	Jonathan Hunter, Mikko Perttunen, Tomeu Vizoso, linux-clk,
	linux-tegra, linux-kernel

On Wed, Jul 08, 2026 at 07:20:58PM +0800, Guangshuo Li wrote:
> tegra124_clk_register_emc() stores a device node reference returned by
> of_parse_phandle() in tegra->emc_node.
> 
> If clk_register() fails, the function returns an error before that
> reference can be consumed and released by the normal runtime path. The
> tegra_clk_emc object is freed on this failure path, but freeing the
> object does not drop the OF node reference stored in it.
> 
> Drop the EMC node reference before freeing the tegra_clk_emc object.
> of_node_put() is safe for a NULL node, so this also covers the case where
> the phandle is absent.
> 
> Fixes: 2db04f16b589 ("clk: tegra: Add EMC clock driver")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>

Reviewed-by: Brian Masney <bmasney@redhat.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-08 16:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08 11:20 [PATCH] clk: tegra: tegra124-emc: put EMC node on register failure Guangshuo Li
2026-07-08 16:41 ` Brian Masney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox