* [PATCH] iio: pressure: mpl115: Fix runtime PM leak in mpl115_read_raw()
@ 2026-09-16 16:38 Wentao Liang
2026-09-17 0:39 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16 16:38 UTC (permalink / raw)
To: andy
Cc: dlechner, jic23, linux-iio, linux-kernel, nuno.sa,
rajat.khandelwal, Wentao Liang, stable
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")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/iio/pressure/mpl115.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c
index 830a5065c008..3266b79bdab8 100644
--- a/drivers/iio/pressure/mpl115.c
+++ b/drivers/iio/pressure/mpl115.c
@@ -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;
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: pressure: mpl115: Fix runtime PM leak in mpl115_read_raw()
2026-09-16 16:38 [PATCH] iio: pressure: mpl115: Fix runtime PM leak in mpl115_read_raw() Wentao Liang
@ 2026-09-17 0:39 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2026-09-17 0:39 UTC (permalink / raw)
To: Wentao Liang
Cc: andy, dlechner, linux-iio, linux-kernel, nuno.sa,
rajat.khandelwal, stable
On Wed, 16 Sep 2026 16:38:52 +0000
Wentao Liang <vulab@iscas.ac.cn> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
see upstream...
> ---
> drivers/iio/pressure/mpl115.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c
> index 830a5065c008..3266b79bdab8 100644
> --- a/drivers/iio/pressure/mpl115.c
> +++ b/drivers/iio/pressure/mpl115.c
> @@ -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;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-17 0:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 16:38 [PATCH] iio: pressure: mpl115: Fix runtime PM leak in mpl115_read_raw() Wentao Liang
2026-09-17 0:39 ` Jonathan Cameron
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®