Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] thermal/drivers/imx: drop the runtime PM reference on early error returns
@ 2026-11-29  6:44 Cong Nguyen
  0 siblings, 0 replies; only message in thread
From: Cong Nguyen @ 2026-11-29  6:44 UTC (permalink / raw)
  To: Rafael J . Wysocki, Daniel Lezcano
  Cc: Zhang Rui, Lukasz Luba, Frank Li, Sascha Hauer, Fabio Estevam,
	linux-pm, imx, linux-arm-kernel, linux-kernel

imx_get_temp() returns -EAGAIN and imx_set_trip_temp() returns -EINVAL
after taking a runtime PM reference, without dropping it. The usage count
stays raised, so the device can no longer runtime suspend.

Drop the reference before returning on those paths.

Fixes: 4cf2ddf16e17 ("thermal/drivers/imx: Implement runtime PM support")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
 drivers/thermal/imx_thermal.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 1a57aa9dc900..3529b4a4cce1 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -266,8 +266,10 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
 
 	regmap_read(map, soc_data->temp_data, &val);
 
-	if ((val & soc_data->temp_valid_mask) == 0)
+	if ((val & soc_data->temp_valid_mask) == 0) {
+		pm_runtime_put(data->dev);
 		return -EAGAIN;
+	}
 
 	n_meas = (val & soc_data->temp_value_mask)
 		>> soc_data->temp_value_shift;
@@ -342,8 +344,10 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz,
 		return ret;
 
 	/* do not allow passive to be set higher than critical */
-	if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature)
+	if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) {
+		pm_runtime_put(data->dev);
 		return -EINVAL;
+	}
 
 	imx_set_alarm_temp(data, temp);
 	trips[IMX_TRIP_PASSIVE].temperature = temp;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-29  6:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  6:44 [PATCH] thermal/drivers/imx: drop the runtime PM reference on early error returns Cong Nguyen

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