From: Biren Pandya <birenpandya@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Linus Walleij" <linusw@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Biren Pandya" <birenpandya@gmail.com>
Subject: [PATCH v1 3/4] iio: pressure: mpl115: fix runtime PM leak on read error
Date: Sun, 14 Jun 2026 12:45:48 +0530 [thread overview]
Message-ID: <20260614071549.81920-4-birenpandya@gmail.com> (raw)
In-Reply-To: <20260614071549.81920-1-birenpandya@gmail.com>
mpl115_read_raw() takes a runtime PM reference with pm_runtime_get_sync()
before reading the processed pressure or raw temperature, but on the read
error path it returns without calling pm_runtime_put_autosuspend(). Each
failed read therefore leaks a runtime PM reference and prevents the device
from autosuspending.
Drop the reference before checking the return value so both the success
and error paths are balanced.
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Assisted-by: Claude:claude-opus-4-8 coccinelle
---
drivers/iio/pressure/mpl115.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c
index 830a5065c008..16e112b796ba 100644
--- a/drivers/iio/pressure/mpl115.c
+++ b/drivers/iio/pressure/mpl115.c
@@ -106,18 +106,18 @@ 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);
+ pm_runtime_put_autosuspend(data->dev);
if (ret < 0)
return ret;
- pm_runtime_put_autosuspend(data->dev);
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_RAW:
pm_runtime_get_sync(data->dev);
/* temperature -5.35 C / LSB, 472 LSB is 25 C */
ret = mpl115_read_temp(data);
+ pm_runtime_put_autosuspend(data->dev);
if (ret < 0)
return ret;
- pm_runtime_put_autosuspend(data->dev);
*val = ret >> 6;
return IIO_VAL_INT;
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-06-14 7:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-14 7:15 [PATCH v1 0/4] iio: Fix runtime PM leaks across multiple drivers Biren Pandya
2026-06-14 7:15 ` [PATCH v1 1/4] iio: accel: kxsd9: fix runtime PM imbalance on write_raw() error Biren Pandya
2026-06-14 13:14 ` Jonathan Cameron
2026-06-14 7:15 ` [PATCH v1 2/4] iio: gyro: mpu3050: fix runtime PM leak when enabling trigger fails Biren Pandya
2026-06-14 13:22 ` Jonathan Cameron
2026-07-17 17:50 ` [PATCH v3] " Biren Pandya
2026-07-17 18:01 ` Andy Shevchenko
2026-07-17 18:10 ` [PATCH v4] " Biren Pandya
2026-06-14 7:15 ` Biren Pandya [this message]
2026-06-14 13:24 ` [PATCH v1 3/4] iio: pressure: mpl115: fix runtime PM leak on read error Jonathan Cameron
2026-06-14 7:15 ` [PATCH v1 4/4] iio: light: gp2ap002: " Biren Pandya
2026-06-14 13:25 ` Jonathan Cameron
2026-06-14 13:31 ` [PATCH v1 0/4] iio: Fix runtime PM leaks across multiple drivers Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260614071549.81920-4-birenpandya@gmail.com \
--to=birenpandya@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox