diff options
| author | Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> | 2024-12-04 20:13:42 +0900 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-01-17 13:34:46 +0100 |
| commit | 6c92d6f2c7a654a56c6ab207f9504e7a9f08c993 (patch) | |
| tree | 27c82bd18cfa37da4ef258d614f2e7e20f5275e6 | |
| parent | 25ef52f1c15db67d890b80203a911b9a57b0bf71 (diff) | |
| download | linux-6c92d6f2c7a654a56c6ab207f9504e7a9f08c993.tar.gz linux-6c92d6f2c7a654a56c6ab207f9504e7a9f08c993.tar.bz2 linux-6c92d6f2c7a654a56c6ab207f9504e7a9f08c993.zip | |
iio: inkern: call iio_device_put() only on mapped devices
commit 64f43895b4457532a3cc524ab250b7a30739a1b1 upstream.
In the error path of iio_channel_get_all(), iio_device_put() is called
on all IIO devices, which can cause a refcount imbalance. Fix this error
by calling iio_device_put() only on IIO devices whose refcounts were
previously incremented by iio_device_get().
Fixes: 314be14bb893 ("iio: Rename _st_ functions to loose the bit that meant the staging version.")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Link: https://patch.msgid.link/20241204111342.1246706-1-joe@pf.is.s.u-tokyo.ac.jp
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/iio/inkern.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 21c07178bd2d..5c210f48bd9c 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -513,7 +513,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev) return chans; error_free_chans: - for (i = 0; i < nummaps; i++) + for (i = 0; i < mapind; i++) iio_device_put(chans[i].indio_dev); kfree(chans); error_ret: |
