[PATCH v2 2/2] cpufreq: spear: Add a platform remove callback

Tian Xuechen 202300460064 at mail.sdu.edu.cn
Mon Nov 30 00:27:51 PST 2026


From: Tian Xuechen <202300460064 at mail.sdu.edu.cn>

The SPEAr platform device registers a cpufreq driver and retains the CPU
clock and frequency table. Unbinding it leaves the driver and those
resources registered.

Unregister the cpufreq driver before dropping the clock reference and
freeing the table.

This issue was found by our static analysis tool under development.

Fixes: 2449d33a4055 ("cpufreq: SPEAr: Instantiate as platform_driver")
Signed-off-by: Tian Xuechen <202300460064 at mail.sdu.edu.cn>
---
 drivers/cpufreq/spear-cpufreq.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 188d4d0b2c56..6c3e6ceefeec 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -233,11 +233,19 @@ static int spear_cpufreq_probe(struct platform_device *pdev)
 	return ret;
 }
 
+static void spear_cpufreq_remove(struct platform_device *pdev)
+{
+	cpufreq_unregister_driver(&spear_cpufreq_driver);
+	clk_put(spear_cpufreq.clk);
+	kfree(spear_cpufreq.freq_tbl);
+}
+
 static struct platform_driver spear_cpufreq_platdrv = {
 	.driver = {
 		.name	= "spear-cpufreq",
 	},
 	.probe		= spear_cpufreq_probe,
+	.remove		= spear_cpufreq_remove,
 };
 module_platform_driver(spear_cpufreq_platdrv);
 



More information about the linux-arm-kernel mailing list