The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2] clk/ingenic: fix clock leak on clk_register_clkdev failure
@ 2026-06-28 12:28 WenTao Liang
  2026-07-06 19:59 ` Brian Masney
  0 siblings, 1 reply; 3+ messages in thread
From: WenTao Liang @ 2026-06-28 12:28 UTC (permalink / raw)
  To: paul, mturquette, sboyd
  Cc: bmasney, linux-mips, linux-clk, linux-kernel, WenTao Liang,
	Greg KH, stable

clk_register() succeeds but clk_register_clkdev() fails, and the error
path jumps to out without calling clk_unregister or clk_put to release
the registered clock. This leaks the clock object within the common clock
framework, contrasting with the CGU_CLK_EXT type path which correctly
calls clk_put on error.

Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Fixes: b066303fb3e7 ("clk: ingenic: add driver for Ingenic SoC CGU clocks")
Cc: stable@vger.kernel.org
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
---
Changes in v2:
- Fix patch format based on reviewer feedback
---
 drivers/clk/ingenic/cgu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/ingenic/cgu.c b/drivers/clk/ingenic/cgu.c
index 41e4c69131bd..b59b24d0e3cf 100644
--- a/drivers/clk/ingenic/cgu.c
+++ b/drivers/clk/ingenic/cgu.c
@@ -774,8 +774,10 @@ static int ingenic_register_clock(struct ingenic_cgu *cgu, unsigned idx)
 	}
 
 	err = clk_register_clkdev(clk, clk_info->name, NULL);
-	if (err)
+	if (err) {
+		clk_unregister(clk);
 		goto out;
+	}
 
 	cgu->clocks.clks[idx] = clk;
 out:
-- 
2.39.5 (Apple Git-154)


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

end of thread, other threads:[~2026-07-07  4:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-28 12:28 [PATCH v2] clk/ingenic: fix clock leak on clk_register_clkdev failure WenTao Liang
2026-07-06 19:59 ` Brian Masney
2026-07-07  4:25   ` Greg KH

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