]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: pressure: mpl115: fix runtime PM leak on read error
authorBiren Pandya <birenpandya@gmail.com>
Sun, 14 Jun 2026 07:15:48 +0000 (12:45 +0530)
committerJonathan Cameron <jic23@kernel.org>
Mon, 29 Jun 2026 22:24:46 +0000 (23:24 +0100)
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.

Fixes: 0c3a333524a3 ("iio: pressure: mpl115: Implementing low power mode by shutdown gpio")
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Assisted-by: Claude:claude-opus-4-8 coccinelle
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/pressure/mpl115.c

index 830a5065c008f88493faac8b03cc382ceeb39420..16e112b796ba9e7aec3a998b5ffc6aff3ac2f5e3 100644 (file)
@@ -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;