Skip to contentSkip to conversation

rtc: jz4740: Make sure clock provider gets removed

PATCH Applied Lars-Peter Clausen 2 participants 2 messages Apr 9, 2023 – Apr 27, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: jz4740: Make sure clock provider gets removed

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")
---
 drivers/rtc/rtc-jz4740.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-jz4740.c +2 -1
index 59d279e3e6f5..36453b008139 100644
@@ -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");
Signature · 1 line
2.30.2
maintainer Applied
#1 lore raw
Quoted 9 lines · 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.

[...]

Applied, thanks!

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

      commit: 4fee39815aafd68ebc6a71b1b1b5d63f0ddde671

Best regards,

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