diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2023-04-13 18:37:52 -0700 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2023-05-13 17:54:56 +0100 |
commit | 265c82ea8b172129cb6d4eff41af856c3aff6168 (patch) | |
tree | 970c7a048c904397d61c7d787db397453b5421f8 /drivers | |
parent | 00ffdd6fa90298522d45ca0c348b23485584dcdc (diff) | |
download | linux-stable-265c82ea8b172129cb6d4eff41af856c3aff6168.tar.gz linux-stable-265c82ea8b172129cb6d4eff41af856c3aff6168.tar.bz2 linux-stable-265c82ea8b172129cb6d4eff41af856c3aff6168.zip |
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: 866a1389174b ("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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/iio/magnetometer/tmag5273.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/iio/magnetometer/tmag5273.c b/drivers/iio/magnetometer/tmag5273.c index 28bb7efe8df8..e155a75b3cd2 100644 --- a/drivers/iio/magnetometer/tmag5273.c +++ b/drivers/iio/magnetometer/tmag5273.c @@ -296,12 +296,13 @@ static int tmag5273_read_raw(struct iio_dev *indio_dev, return ret; ret = tmag5273_get_measure(data, &t, &x, &y, &z, &angle, &magnitude); - if (ret) - return ret; pm_runtime_mark_last_busy(data->dev); pm_runtime_put_autosuspend(data->dev); + if (ret) + return ret; + switch (chan->address) { case TEMPERATURE: *val = t; |