Skip to content

Commit aa2ad19

Browse files
ISCAS-Vulabbebarino
authored andcommitted
clk: mediatek: Fix error handling in runtime PM setup
devm_pm_runtime_enable() can fail due to memory allocation. The current code ignores its return value, and when pm_runtime_resume_and_get() fails, it returns directly without unmapping the shared_io region. Add error handling for devm_pm_runtime_enable(). Reorder cleanup labels to properly unmap shared_io on pm_runtime_resume_and_get() failure. Fixes: 2f7b1d8 ("clk: mediatek: Do a runtime PM get on controllers during probe") Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 963bb18 commit aa2ad19

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

drivers/clk/mediatek/clk-mtk.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,16 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
497497

498498

499499
if (mcd->need_runtime_pm) {
500-
devm_pm_runtime_enable(&pdev->dev);
500+
r = devm_pm_runtime_enable(&pdev->dev);
501+
if (r)
502+
goto unmap_io;
501503
/*
502504
* Do a pm_runtime_resume_and_get() to workaround a possible
503505
* deadlock between clk_register() and the genpd framework.
504506
*/
505507
r = pm_runtime_resume_and_get(&pdev->dev);
506508
if (r)
507-
return r;
509+
goto unmap_io;
508510
}
509511

510512
/* Calculate how many clk_hw_onecell_data entries to allocate */
@@ -618,11 +620,11 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
618620
free_data:
619621
mtk_free_clk_data(clk_data);
620622
free_base:
621-
if (mcd->shared_io && base)
622-
iounmap(base);
623-
624623
if (mcd->need_runtime_pm)
625624
pm_runtime_put(&pdev->dev);
625+
unmap_io:
626+
if (mcd->shared_io && base)
627+
iounmap(base);
626628
return r;
627629
}
628630

0 commit comments

Comments
 (0)