Skip to content

Commit 265c82e

Browse files
larsclausenjic23
authored andcommitted
iio: tmag5273: Fix runtime PM leak on measurement error
The tmag5273 gets a runtime PM reference before reading a measurement and releases it when done. But if the measurement fails the tmag5273_read_raw() function exits before releasing the reference. Make sure that this error path also releases the runtime PM reference. Fixes: 866a138 ("iio: magnetometer: add ti tmag5273 driver") Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Gerald Loacker <gerald.loacker@wolfvision.net> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20230414013752.498767-1-lars@metafoo.de Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 00ffdd6 commit 265c82e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/iio/magnetometer/tmag5273.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,13 @@ static int tmag5273_read_raw(struct iio_dev *indio_dev,
296296
return ret;
297297

298298
ret = tmag5273_get_measure(data, &t, &x, &y, &z, &angle, &magnitude);
299-
if (ret)
300-
return ret;
301299

302300
pm_runtime_mark_last_busy(data->dev);
303301
pm_runtime_put_autosuspend(data->dev);
304302

303+
if (ret)
304+
return ret;
305+
305306
switch (chan->address) {
306307
case TEMPERATURE:
307308
*val = t;

0 commit comments

Comments
 (0)