Skip to content

Commit ebc4ed1

Browse files
jhovoldvireshk
authored andcommitted
cpufreq: mediatek: fix device leak on probe failure
Make sure to drop the reference to the cci device taken by of_find_device_by_node() on probe failure (e.g. probe deferral). Fixes: 0daa473 ("cpufreq: mediatek: Link CCI device to CPU") Cc: Jia-Wei Chang <jia-wei.chang@mediatek.com> Cc: Rex-BC Chen <rex-bc.chen@mediatek.com> Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 3e68189 commit ebc4ed1

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

drivers/cpufreq/mediatek-cpufreq.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,11 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
403403
}
404404

405405
info->cpu_clk = clk_get(cpu_dev, "cpu");
406-
if (IS_ERR(info->cpu_clk))
407-
return dev_err_probe(cpu_dev, PTR_ERR(info->cpu_clk),
408-
"cpu%d: failed to get cpu clk\n", cpu);
406+
if (IS_ERR(info->cpu_clk)) {
407+
ret = PTR_ERR(info->cpu_clk);
408+
dev_err_probe(cpu_dev, ret, "cpu%d: failed to get cpu clk\n", cpu);
409+
goto out_put_cci_dev;
410+
}
409411

410412
info->inter_clk = clk_get(cpu_dev, "intermediate");
411413
if (IS_ERR(info->inter_clk)) {
@@ -551,6 +553,10 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
551553
out_free_mux_clock:
552554
clk_put(info->cpu_clk);
553555

556+
out_put_cci_dev:
557+
if (info->soc_data->ccifreq_supported)
558+
put_device(info->cci_dev);
559+
554560
return ret;
555561
}
556562

@@ -568,6 +574,8 @@ static void mtk_cpu_dvfs_info_release(struct mtk_cpu_dvfs_info *info)
568574
clk_put(info->inter_clk);
569575
dev_pm_opp_of_cpumask_remove_table(&info->cpus);
570576
dev_pm_opp_unregister_notifier(info->cpu_dev, &info->opp_nb);
577+
if (info->soc_data->ccifreq_supported)
578+
put_device(info->cci_dev);
571579
}
572580

573581
static int mtk_cpufreq_init(struct cpufreq_policy *policy)

0 commit comments

Comments
 (0)