Skip to contentSkip to conversation

cpufreq: davinci: Fix clk use after free

PATCH New Vasiliy Kovalev 1 participant 1 message Oct 22, 2025 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: davinci: Fix clk use after free

From: Uwe Kleine-König <[email protected]>

[ Upstream commit 5d8f384a9b4fc50f6a18405f1c08e5a87a77b5b3 ]

The remove function first frees the clks and only then calls cpufreq_unregister_driver(). If one of the cpufreq callbacks is called just before cpufreq_unregister_driver() is run, the freed clks might be used.

Fixes 6601b8030de3 ("davinci: add generic CPUFreq driver for DaVinci")
(cherry picked from commit a5f024d0e6f91e05c816ad4ee8837173369dd5cb)
[ kovalev: bp to fix CVE-2023-53544 ]
---
 drivers/cpufreq/davinci-cpufreq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/davinci-cpufreq.c +3 -1
index 91f477a6cbc4..62380f05aec8 100644
@@ -133,12 +133,14 @@ static int __init davinci_cpufreq_probe(struct platform_device *pdev)
 
 static int __exit davinci_cpufreq_remove(struct platform_device *pdev)
 {
+	cpufreq_unregister_driver(&davinci_driver);
+
 	clk_put(cpufreq.armclk);
 
 	if (cpufreq.asyncclk)
 		clk_put(cpufreq.asyncclk);
 
-	return cpufreq_unregister_driver(&davinci_driver);
+	return 0;
 }
 
 static struct platform_driver davinci_cpufreq_driver = {
Signature · 1 line
2.50.1