Skip to content

Commit 91dd568

Browse files
joehattorigregkh
authored andcommitted
iio: inkern: call iio_device_put() only on mapped devices
commit 64f4389 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: 314be14 ("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>
1 parent 09e067e commit 91dd568

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/inkern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
514514
return chans;
515515

516516
error_free_chans:
517-
for (i = 0; i < nummaps; i++)
517+
for (i = 0; i < mapind; i++)
518518
iio_device_put(chans[i].indio_dev);
519519
kfree(chans);
520520
error_ret:

0 commit comments

Comments
 (0)