mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] clocksource/drivers/st_lpc: Fix clock reference leaks
@ 2026-09-15  5:48 Wentao Liang
  2026-09-15  9:28 ` Patrice CHOTARD
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-15  5:48 UTC (permalink / raw)
  To: daniel.lezcano
  Cc: lee, linux-arm-kernel, linux-kernel, patrice.chotard, tglx,
	Wentao Liang, stable

st_clksrc_setup_clk() obtains the LPC clock with of_clk_get() but
leaks the consumer reference on two error paths: the
clk_prepare_enable() failure path returns without any release, and the
clk_get_rate() == 0 path only does clk_disable_unprepare() without
clk_put().

Add the missing clk_put() calls, mirroring the release already done in
st_clksrc_of_register() error handling.

Fixes: 70bef01c0f1c ("clocksource: sti: Provide support for the ST LPC Clocksource IP")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/clocksource/clksrc_st_lpc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clocksource/clksrc_st_lpc.c b/drivers/clocksource/clksrc_st_lpc.c
index 419a886876e4..574b966eeb34 100644
--- a/drivers/clocksource/clksrc_st_lpc.c
+++ b/drivers/clocksource/clksrc_st_lpc.c
@@ -74,12 +74,14 @@ static int __init st_clksrc_setup_clk(struct device_node *np)
 
 	if (clk_prepare_enable(clk)) {
 		pr_err("clksrc-st-lpc: Failed to enable LPC clock\n");
+		clk_put(clk);
 		return -EINVAL;
 	}
 
 	if (!clk_get_rate(clk)) {
 		pr_err("clksrc-st-lpc: Failed to get LPC clock rate\n");
 		clk_disable_unprepare(clk);
+		clk_put(clk);
 		return -EINVAL;
 	}
 
-- 
2.34.1


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

end of thread, other threads:[~2026-09-15  9:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15  5:48 [PATCH] clocksource/drivers/st_lpc: Fix clock reference leaks Wentao Liang
2026-09-15  9:28 ` Patrice CHOTARD

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

all inboxes | Powered by JetHome®