public inbox for linux-amlogic@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] rtc: amlogic-a4: fix double free caused by devm
@ 2025-10-20 15:09 Haotian Zhang
  2025-10-21  9:29 ` kernel test robot
  2025-10-21 10:35 ` [PATCH v2] " Haotian Zhang
  0 siblings, 2 replies; 5+ messages in thread
From: Haotian Zhang @ 2025-10-20 15:09 UTC (permalink / raw)
  To: Yiting Deng, Xianwei Zhao, Alexandre Belloni
  Cc: linux-amlogic, linux-rtc, linux-kernel, stable, Haotian Zhang

The clock obtained via devm_clk_get_enabled() is automatically managed
by devres and will be disabled and freed on driver detach. Manually
calling clk_disable_unprepare() in error path and remove function
causes double free.

Remove the redundant clk_disable_unprepare() calls from the probe
error path and aml_rtc_remove(), allowing the devm framework to
automatically manage the clock lifecycle.

Fixes: c89ac9182ee2 ("rtc: support for the Amlogic on-chip RTC")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/rtc/rtc-amlogic-a4.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/rtc/rtc-amlogic-a4.c b/drivers/rtc/rtc-amlogic-a4.c
index 1928b29c1045..ed36b649c057 100644
--- a/drivers/rtc/rtc-amlogic-a4.c
+++ b/drivers/rtc/rtc-amlogic-a4.c
@@ -390,7 +390,6 @@ static int aml_rtc_probe(struct platform_device *pdev)
 
 	return 0;
 err_clk:
-	clk_disable_unprepare(rtc->sys_clk);
 	device_init_wakeup(dev, false);
 
 	return ret;
@@ -425,7 +424,6 @@ static void aml_rtc_remove(struct platform_device *pdev)
 {
 	struct aml_rtc_data *rtc = dev_get_drvdata(&pdev->dev);
 
-	clk_disable_unprepare(rtc->sys_clk);
 	device_init_wakeup(&pdev->dev, false);
 }
 
-- 
2.25.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, other threads:[~2025-10-31 23:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 15:09 [PATCH] rtc: amlogic-a4: fix double free caused by devm Haotian Zhang
2025-10-21  9:29 ` kernel test robot
2025-10-21 10:35 ` [PATCH v2] " Haotian Zhang
2025-10-22  5:48   ` Xianwei Zhao
2025-10-31 23:02   ` Alexandre Belloni

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