]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iio: inkern: call iio_device_put() only on mapped devices
authorJoe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Wed, 4 Dec 2024 11:13:42 +0000 (20:13 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Jan 2025 16:15:55 +0000 (17:15 +0100)
commitd83ccca9e17eb738cb38292234590a510e8578df
treeb5f2c7e11e4fcc319610cadba2714ceabe14710d
parent028a1ba8e3bae593d701aee4f690ce7c195b67d6
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>
drivers/iio/inkern.c