]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iio: light: bh1780: fix PM runtime leak on error path
authorAntoniu Miclaus <antoniu.miclaus@analog.com>
Fri, 30 Jan 2026 11:30:20 +0000 (13:30 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 23 Feb 2026 08:24:37 +0000 (08:24 +0000)
Move pm_runtime_put_autosuspend() before the error check to ensure
the PM runtime reference count is always decremented after
pm_runtime_get_sync(), regardless of whether the read operation
succeeds or fails.

Fixes: 1f0477f18306 ("iio: light: new driver for the ROHM BH1780")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/bh1780.c

index 5d3c6d5276bac64152bca317f57e5a01d7fd93bd..a740d1f992a8a13de44a22623f99d3aecae7f99c 100644 (file)
@@ -109,9 +109,9 @@ static int bh1780_read_raw(struct iio_dev *indio_dev,
                case IIO_LIGHT:
                        pm_runtime_get_sync(&bh1780->client->dev);
                        value = bh1780_read_word(bh1780, BH1780_REG_DLOW);
+                       pm_runtime_put_autosuspend(&bh1780->client->dev);
                        if (value < 0)
                                return value;
-                       pm_runtime_put_autosuspend(&bh1780->client->dev);
                        *val = value;
 
                        return IIO_VAL_INT;