* [PATCH] iio: inkern: call iio_device_put() only on mapped devices
@ 2024-12-04 11:13 Joe Hattori
2024-12-08 16:49 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Joe Hattori @ 2024-12-04 11:13 UTC (permalink / raw)
To: jic23, lars; +Cc: linux-iio, Joe Hattori
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>
---
drivers/iio/inkern.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 136b225b6bc8..9050a59129e6 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -500,7 +500,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
return_ptr(chans);
error_free_chans:
- for (i = 0; i < nummaps; i++)
+ for (i = 0; i < mapind; i++)
iio_device_put(chans[i].indio_dev);
return ERR_PTR(ret);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] iio: inkern: call iio_device_put() only on mapped devices
2024-12-04 11:13 [PATCH] iio: inkern: call iio_device_put() only on mapped devices Joe Hattori
@ 2024-12-08 16:49 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-12-08 16:49 UTC (permalink / raw)
To: Joe Hattori; +Cc: lars, linux-iio
On Wed, 4 Dec 2024 20:13:42 +0900
Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> wrote:
> 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>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
> ---
> drivers/iio/inkern.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 136b225b6bc8..9050a59129e6 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -500,7 +500,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
> return_ptr(chans);
>
> error_free_chans:
> - for (i = 0; i < nummaps; i++)
> + for (i = 0; i < mapind; i++)
> iio_device_put(chans[i].indio_dev);
> return ERR_PTR(ret);
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-08 16:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-04 11:13 [PATCH] iio: inkern: call iio_device_put() only on mapped devices Joe Hattori
2024-12-08 16:49 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox