Skip to content

Commit 33661bf

Browse files
amiclausgregkh
authored andcommitted
iio: light: bh1780: fix PM runtime leak on error path
commit dd72e6c upstream. 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: 1f0477f ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent acce8eb commit 33661bf

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iio/light/bh1780.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ static int bh1780_read_raw(struct iio_dev *indio_dev,
109109
case IIO_LIGHT:
110110
pm_runtime_get_sync(&bh1780->client->dev);
111111
value = bh1780_read_word(bh1780, BH1780_REG_DLOW);
112+
pm_runtime_put_autosuspend(&bh1780->client->dev);
112113
if (value < 0)
113114
return value;
114-
pm_runtime_put_autosuspend(&bh1780->client->dev);
115115
*val = value;
116116

117117
return IIO_VAL_INT;

0 commit comments

Comments
 (0)