mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:24:45 +01:00
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: 2f7b1d8b55 ("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>
This commit is contained in:
parent
963bb1866c
commit
aa2ad19210
1 changed files with 7 additions and 5 deletions
|
|
@ -497,14 +497,16 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
|
|||
|
||||
|
||||
if (mcd->need_runtime_pm) {
|
||||
devm_pm_runtime_enable(&pdev->dev);
|
||||
r = devm_pm_runtime_enable(&pdev->dev);
|
||||
if (r)
|
||||
goto unmap_io;
|
||||
/*
|
||||
* Do a pm_runtime_resume_and_get() to workaround a possible
|
||||
* deadlock between clk_register() and the genpd framework.
|
||||
*/
|
||||
r = pm_runtime_resume_and_get(&pdev->dev);
|
||||
if (r)
|
||||
return r;
|
||||
goto unmap_io;
|
||||
}
|
||||
|
||||
/* Calculate how many clk_hw_onecell_data entries to allocate */
|
||||
|
|
@ -618,11 +620,11 @@ unregister_fixed_clks:
|
|||
free_data:
|
||||
mtk_free_clk_data(clk_data);
|
||||
free_base:
|
||||
if (mcd->shared_io && base)
|
||||
iounmap(base);
|
||||
|
||||
if (mcd->need_runtime_pm)
|
||||
pm_runtime_put(&pdev->dev);
|
||||
unmap_io:
|
||||
if (mcd->shared_io && base)
|
||||
iounmap(base);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue