Skip to content

Commit a648367

Browse files
amiclausopsiff
authored andcommitted
iio: light: bh1780: fix PM runtime leak on error path
[ Upstream commit dd72e6c3cdea05cad24e99710939086f7a113fb5 ] 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> [ moved both pm_runtime_mark_last_busy() and pm_runtime_put_autosuspend() before the error check instead of just pm_runtime_put_autosuspend() ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit fc77e0a5600e620a2ae51ec78933162fb217b20b) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 3a76c0c commit a648367

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/iio/light/bh1780.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ 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-
if (value < 0)
113-
return value;
114112
pm_runtime_mark_last_busy(&bh1780->client->dev);
115113
pm_runtime_put_autosuspend(&bh1780->client->dev);
114+
if (value < 0)
115+
return value;
116116
*val = value;
117117

118118
return IIO_VAL_INT;

0 commit comments

Comments
 (0)