[PATCH 2/2] cpufreq: spear: Add a platform remove callback
Tian Xuechen
202300460064 at mail.sdu.edu.cn
Fri Nov 27 03:33:22 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 ffe5eda82f0b..91aeaa099f8f 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -229,11 +229,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);
--
2.43.0
More information about the linux-arm-kernel
mailing list