Skip to contentSkip to conversation

cpufreq: s3c2416: double free on driver init error path

PATCH In review Dan Carpenter 4 participants 4 messages Feb 7, 2017 – Feb 9, 2017

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

PATCH 1/1 cpufreq: s3c2416: double free on driver init error path

The "goto err_armclk;" error path already does a clk_put(s3c_freq->hclk); so this is a double free.

Fixes 34ee55075265 ("[CPUFREQ] Add S3C2416/S3C2450 cpufreq driver")
drivers/cpufreq/s3c2416-cpufreq.c +0 -1
index d6d425773fa4..5b2db3c6568f 100644
@@ -400,7 +400,6 @@ static int s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy)
 	rate = clk_get_rate(s3c_freq->hclk);
 	if (rate < 133 * 1000 * 1000) {
 		pr_err("cpufreq: HCLK not at 133MHz\n");
-		clk_put(s3c_freq->hclk);
 		ret = -EINVAL;
 		goto err_armclk;
 	}
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 11 lines · Dan Carpenter

The "goto err_armclk;" error path already does a clk_put(s3c_freq->hclk); so this is a double free.

Fixes 34ee55075265 ("[CPUFREQ] Add S3C2416/S3C2450 cpufreq driver")
drivers/cpufreq/s3c2416-cpufreq.c +0 -0
index d6d425773fa4..5b2db3c6568f 100644

drivers/cpufreq/s3c2416-cpufreq.c static int s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy) · line 405

Quoted 7 lines
drivers/cpufreq/s3c2416-cpufreq.c +0 -1
@@ -400,7 +400,6 @@ static int s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy)
 	rate = clk_get_rate(s3c_freq->hclk);
 	if (rate < 133 * 1000 * 1000) {
 		pr_err("cpufreq: HCLK not at 133MHz\n");
-		clk_put(s3c_freq->hclk);
 		ret = -EINVAL;
 		goto err_armclk;
 	}
Signature · 1 line
viresh
Reviewed-by on v1 1/1
#3 lore raw
In reply to Dan Carpenter

Hi Dan,

Am Dienstag, 7. Februar 2017, 16:19:06 CET schrieb Dan Carpenter:

Quoted 5 lines

The "goto err_armclk;" error path already does a clk_put(s3c_freq->hclk); so this is a double free.

Fixes 34ee55075265 ("[CPUFREQ] Add S3C2416/S3C2450 cpufreq driver")

Interesting, you found a mistake I made 5 years ago.
It always amazes me how much time I already spent in kernel-land :-) .

Thanks for finding and fixing this
Heiko

Quoted 12 lines
(quoted diff) +0 -0

b/drivers/cpufreq/s3c2416-cpufreq.c index d6d425773fa4..5b2db3c6568f 100644

drivers/cpufreq/s3c2416-cpufreq.c +0 -1
@@ -400,7 +400,6 @@ static int s3c2416_cpufreq_driver_init(struct
 cpufreq_policy *policy) rate = clk_get_rate(s3c_freq->hclk);
 	if (rate < 133 * 1000 * 1000) {
 		pr_err("cpufreq: HCLK not at 133MHz\n");
-		clk_put(s3c_freq->hclk);
 		ret = -EINVAL;
 		goto err_armclk;
 	}