Skip to content

Commit 2de5cb9

Browse files
sfu2vireshk
authored andcommitted
cpufreq: s5pv210: fix refcount leak
In function `s5pv210_cpu_init`, a possible refcount inconsistency has been identified, causing a resource leak. Why it is a bug: 1. For every clk_get, there should be a matching clk_put on every successive error handling path. 2. After calling `clk_get(dmc1_clk)`, variable `dmc1_clk` will not be freed even if any error happens. How it is fixed: For every failed path, an extra goto label is added to ensure `dmc1_clk` will be freed regardlessly. Signed-off-by: Shuhao Fu <sfual@cse.ust.hk> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 211ddde commit 2de5cb9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/cpufreq/s5pv210-cpufreq.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static int s5pv210_cpu_init(struct cpufreq_policy *policy)
518518

519519
if (policy->cpu != 0) {
520520
ret = -EINVAL;
521-
goto out_dmc1;
521+
goto out;
522522
}
523523

524524
/*
@@ -530,7 +530,7 @@ static int s5pv210_cpu_init(struct cpufreq_policy *policy)
530530
if ((mem_type != LPDDR) && (mem_type != LPDDR2)) {
531531
pr_err("CPUFreq doesn't support this memory type\n");
532532
ret = -EINVAL;
533-
goto out_dmc1;
533+
goto out;
534534
}
535535

536536
/* Find current refresh counter and frequency each DMC */
@@ -544,6 +544,8 @@ static int s5pv210_cpu_init(struct cpufreq_policy *policy)
544544
cpufreq_generic_init(policy, s5pv210_freq_table, 40000);
545545
return 0;
546546

547+
out:
548+
clk_put(dmc1_clk);
547549
out_dmc1:
548550
clk_put(dmc0_clk);
549551
out_dmc0:

0 commit comments

Comments
 (0)