mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pwm: tegra: Disable runtime PM on cleanup errors
@ 2026-09-13  4:06 Myeonghun Pak
  2026-09-14  6:20 ` Mikko Perttunen
  0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-09-13  4:06 UTC (permalink / raw)
  To: Thierry Reding, Uwe Kleine-König, Jonathan Hunter
  Cc: Dmitry Osipenko, Ulf Hansson, linux-pwm, linux-tegra,
	linux-kernel, stable, Ijae Kim

tegra_pwm_probe() enables runtime PM before requesting the initial resume.
If pm_runtime_resume_and_get() fails, probe returns with runtime PM still
enabled as the managed driver resources are released.

The later probe unwind and remove paths use pm_runtime_force_suspend(),
which disables runtime PM on success but enables it again if the suspend
callback fails. Ignoring that error can therefore also leave runtime PM
enabled during resource cleanup.

Disable runtime PM on the initial resume failure and when force-suspend
fails. Do not disable it a second time after successful force-suspend, and
preserve the original probe error. The failed resume_and_get call has
already balanced its usage count, so it needs no additional put.

This issue was identified during our ongoing static-analysis research while
reviewing kernel code.

Fixes: 3da9b0feaa16 ("pwm: tegra: Add runtime PM and OPP support")
Cc: stable@vger.kernel.org
Assisted-by: OpenAI:GPT-5.6
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/pwm/pwm-tegra.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
index 5cdbe120b..55287afcb 100644
--- a/drivers/pwm/pwm-tegra.c
+++ b/drivers/pwm/pwm-tegra.c
@@ -346,8 +346,10 @@ static int tegra_pwm_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(&pdev->dev);
 	ret = pm_runtime_resume_and_get(&pdev->dev);
-	if (ret)
+	if (ret) {
+		pm_runtime_disable(&pdev->dev);
 		return ret;
+	}
 
 	/* Set maximum frequency of the IP */
 	ret = dev_pm_opp_set_rate(&pdev->dev, ULONG_MAX);
@@ -395,7 +397,8 @@ static int tegra_pwm_probe(struct platform_device *pdev)
 	return 0;
 put_pm:
 	pm_runtime_put_sync_suspend(&pdev->dev);
-	pm_runtime_force_suspend(&pdev->dev);
+	if (pm_runtime_force_suspend(&pdev->dev))
+		pm_runtime_disable(&pdev->dev);
 	return ret;
 }
 
@@ -408,7 +411,8 @@ static void tegra_pwm_remove(struct platform_device *pdev)
 
 	reset_control_assert(pc->rst);
 
-	pm_runtime_force_suspend(&pdev->dev);
+	if (pm_runtime_force_suspend(&pdev->dev))
+		pm_runtime_disable(&pdev->dev);
 }
 
 static int __maybe_unused tegra_pwm_runtime_suspend(struct device *dev)

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

end of thread, other threads:[~2026-09-14  6:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-13  4:06 [PATCH] pwm: tegra: Disable runtime PM on cleanup errors Myeonghun Pak
2026-09-14  6:20 ` Mikko Perttunen

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

all inboxes | Powered by JetHome®