linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: jz4740: Make sure clock provider gets removed
@ 2023-04-09 16:25 Lars-Peter Clausen
  2023-04-27 22:43 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Lars-Peter Clausen @ 2023-04-09 16:25 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: Paul Cercueil, linux-rtc, Lars-Peter Clausen

The jz4740 RTC driver registers a clock provider, but never removes it.
This leaves a stale clock provider behind that references freed clocks when
the device is unbound.

Use the managed `devm_of_clk_add_hw_provider()` instead of
`of_clk_add_hw_provider()` to make sure the provider gets automatically
removed on unbind.

Fixes: 5ddfa148de8c ("rtc: jz4740: Register clock provider for the CLK32K pin")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/rtc/rtc-jz4740.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
index 59d279e3e6f5..36453b008139 100644
--- a/drivers/rtc/rtc-jz4740.c
+++ b/drivers/rtc/rtc-jz4740.c
@@ -414,7 +414,8 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
 			return dev_err_probe(dev, ret,
 					     "Unable to register clk32k clock\n");
 
-		ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &rtc->clk32k);
+		ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
+						  &rtc->clk32k);
 		if (ret)
 			return dev_err_probe(dev, ret,
 					     "Unable to register clk32k clock provider\n");
-- 
2.30.2


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

* Re: [PATCH] rtc: jz4740: Make sure clock provider gets removed
  2023-04-09 16:25 [PATCH] rtc: jz4740: Make sure clock provider gets removed Lars-Peter Clausen
@ 2023-04-27 22:43 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2023-04-27 22:43 UTC (permalink / raw)
  To: Alessandro Zummo, Lars-Peter Clausen; +Cc: Paul Cercueil, linux-rtc


On Sun, 09 Apr 2023 09:25:44 -0700, Lars-Peter Clausen wrote:
> The jz4740 RTC driver registers a clock provider, but never removes it.
> This leaves a stale clock provider behind that references freed clocks when
> the device is unbound.
> 
> Use the managed `devm_of_clk_add_hw_provider()` instead of
> `of_clk_add_hw_provider()` to make sure the provider gets automatically
> removed on unbind.
> 
> [...]

Applied, thanks!

[1/1] rtc: jz4740: Make sure clock provider gets removed
      commit: 4fee39815aafd68ebc6a71b1b1b5d63f0ddde671

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2023-04-27 22:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-09 16:25 [PATCH] rtc: jz4740: Make sure clock provider gets removed Lars-Peter Clausen
2023-04-27 22:43 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).