public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] omap-cpufreq: Fix regulator resource leak in probe()
@ 2025-12-15  3:03 Haotian Zhang
  2026-01-05  5:16 ` Viresh Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Haotian Zhang @ 2025-12-15  3:03 UTC (permalink / raw)
  To: Kevin Hilman, Rafael J . Wysocki, Viresh Kumar
  Cc: linux-omap, linux-pm, linux-kernel, Haotian Zhang

The current omap_cpufreq_probe() uses regulator_get() to obtain the MPU
regulator but does not release it in omap_cpufreq_remove() or when
cpufreq_register_driver() fails, leading to a potential resource leak.

Use devm_regulator_get() instead of regulator_get() so that the regulator
resource is automatically released.

Fixes: 53dfe8a884e6 ("cpufreq: OMAP: scale voltage along with frequency")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/cpufreq/omap-cpufreq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index bbb01d93b54b..f83f85996b36 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -157,7 +157,7 @@ static int omap_cpufreq_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	mpu_reg = regulator_get(mpu_dev, "vcc");
+	mpu_reg = devm_regulator_get(mpu_dev, "vcc");
 	if (IS_ERR(mpu_reg)) {
 		pr_warn("%s: unable to get MPU regulator\n", __func__);
 		mpu_reg = NULL;
@@ -169,7 +169,6 @@ static int omap_cpufreq_probe(struct platform_device *pdev)
 		if (regulator_get_voltage(mpu_reg) < 0) {
 			pr_warn("%s: physical regulator not present for MPU\n",
 				__func__);
-			regulator_put(mpu_reg);
 			mpu_reg = NULL;
 		}
 	}
-- 
2.50.1.windows.1


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

end of thread, other threads:[~2026-01-07  7:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-15  3:03 [PATCH] omap-cpufreq: Fix regulator resource leak in probe() Haotian Zhang
2026-01-05  5:16 ` Viresh Kumar
2026-01-05  9:14 ` Andreas Kemnade
2026-01-06  4:50   ` Viresh Kumar
2026-01-06 17:29     ` Andreas Kemnade
2026-01-07  5:57       ` Viresh Kumar
2026-01-07  7:58         ` Andreas Kemnade
2026-01-05 13:12 ` [PATCH v2] cpufreq: OMAP: Fix resource leak in probe error path and remove Haotian Zhang
2026-01-06  4:51   ` Viresh Kumar

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