Skip to contentSkip to conversation

iio: pressure: mpl115: Fix runtime PM leak in mpl115_read_raw()

PATCH In review Wentao Liang 2 participants 2 messages Sep 16 – Sep 17

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: pressure: mpl115: Fix runtime PM leak in mpl115_read_raw()

pm_runtime_get_sync() increments the usage counter even on failure, so every successful call must be paired with a put. Both sensor read failures returned early and skipped the paired pm_runtime_put_autosuspend(), permanently preventing runtime suspend.

Fixes 0c3a333524a3 ("iio: pressure: mpl115: Implementing low power mode by shutdown gpio")
---
 drivers/iio/pressure/mpl115.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iio/pressure/mpl115.c +6 -2
index 830a5065c008..3266b79bdab8 100644
@@ -106,8 +106,10 @@ static int mpl115_read_raw(struct iio_dev *indio_dev,
 	case IIO_CHAN_INFO_PROCESSED:
 		pm_runtime_get_sync(data->dev);
 		ret = mpl115_comp_pressure(data, val, val2);
-		if (ret < 0)
+		if (ret < 0) {
+			pm_runtime_put_autosuspend(data->dev);
 			return ret;
+		}
 		pm_runtime_put_autosuspend(data->dev);
 
 		return IIO_VAL_INT_PLUS_MICRO;
@@ -115,8 +117,10 @@ static int mpl115_read_raw(struct iio_dev *indio_dev,
 		pm_runtime_get_sync(data->dev);
 		/* temperature -5.35 C / LSB, 472 LSB is 25 C */
 		ret = mpl115_read_temp(data);
-		if (ret < 0)
+		if (ret < 0) {
+			pm_runtime_put_autosuspend(data->dev);
 			return ret;
+		}
 		pm_runtime_put_autosuspend(data->dev);
 		*val = ret >> 6;
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 8 lines · On Wed, 16 Sep 2026 16:38:52 +0000 Wentao Liang <[email protected]> wrote:

pm_runtime_get_sync() increments the usage counter even on failure, so every successful call must be paired with a put. Both sensor read failures returned early and skipped the paired pm_runtime_put_autosuspend(), permanently preventing runtime suspend.

Fixes 0c3a333524a3 ("iio: pressure: mpl115: Implementing low power mode by shutdown gpio")

see upstream...

Quoted 32 lines
---
 drivers/iio/pressure/mpl115.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iio/pressure/mpl115.c +6 -2
index 830a5065c008..3266b79bdab8 100644
@@ -106,8 +106,10 @@ static int mpl115_read_raw(struct iio_dev *indio_dev,
 	case IIO_CHAN_INFO_PROCESSED:
 		pm_runtime_get_sync(data->dev);
 		ret = mpl115_comp_pressure(data, val, val2);
-		if (ret < 0)
+		if (ret < 0) {
+			pm_runtime_put_autosuspend(data->dev);
 			return ret;
+		}
 		pm_runtime_put_autosuspend(data->dev);
 
 		return IIO_VAL_INT_PLUS_MICRO;
@@ -115,8 +117,10 @@ static int mpl115_read_raw(struct iio_dev *indio_dev,
 		pm_runtime_get_sync(data->dev);
 		/* temperature -5.35 C / LSB, 472 LSB is 25 C */
 		ret = mpl115_read_temp(data);
-		if (ret < 0)
+		if (ret < 0) {
+			pm_runtime_put_autosuspend(data->dev);
 			return ret;
+		}
 		pm_runtime_put_autosuspend(data->dev);
 		*val = ret >> 6;