Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: mediatek: Fix error handling in runtime PM setup
@ 2025-11-23 15:43 Haotian Zhang
  2025-11-24  8:47 ` AngeloGioacchino Del Regno
  2026-01-23  1:47 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Haotian Zhang @ 2025-11-23 15:43 UTC (permalink / raw)
  To: mturquette, sboyd, matthias.bgg, angelogioacchino.delregno
  Cc: nfraprado, laura.nao, wenst, linux-clk, linux-kernel,
	linux-arm-kernel, linux-mediatek, Haotian Zhang

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: 2f7b1d8b5505 ("clk: mediatek: Do a runtime PM get on controllers during probe")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/clk/mediatek/clk-mtk.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index ba1d1c495bc2..644e5a854f2b 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -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 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
 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;
 }
 
-- 
2.50.1.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: mediatek: Fix error handling in runtime PM setup
  2025-11-23 15:43 [PATCH] clk: mediatek: Fix error handling in runtime PM setup Haotian Zhang
@ 2025-11-24  8:47 ` AngeloGioacchino Del Regno
  2026-01-23  1:47 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-11-24  8:47 UTC (permalink / raw)
  To: Haotian Zhang, mturquette, sboyd, matthias.bgg
  Cc: nfraprado, laura.nao, wenst, linux-clk, linux-kernel,
	linux-arm-kernel, linux-mediatek

Il 23/11/25 16:43, Haotian Zhang ha scritto:
> 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: 2f7b1d8b5505 ("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>




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: mediatek: Fix error handling in runtime PM setup
  2025-11-23 15:43 [PATCH] clk: mediatek: Fix error handling in runtime PM setup Haotian Zhang
  2025-11-24  8:47 ` AngeloGioacchino Del Regno
@ 2026-01-23  1:47 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2026-01-23  1:47 UTC (permalink / raw)
  To: Haotian Zhang, angelogioacchino.delregno, matthias.bgg,
	mturquette
  Cc: nfraprado, laura.nao, wenst, linux-clk, linux-kernel,
	linux-arm-kernel, linux-mediatek, Haotian Zhang

Quoting Haotian Zhang (2025-11-23 08:43:15)
> 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: 2f7b1d8b5505 ("clk: mediatek: Do a runtime PM get on controllers during probe")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---

Applied to clk-next


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-23  1:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-23 15:43 [PATCH] clk: mediatek: Fix error handling in runtime PM setup Haotian Zhang
2025-11-24  8:47 ` AngeloGioacchino Del Regno
2026-01-23  1:47 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox