mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: addac: ad74413r: Fix trigger reference leak in ad74413r_probe()
@ 2026-09-16 16:22 Wentao Liang
  2026-09-17  0:28 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16 16:22 UTC (permalink / raw)
  To: Michael.Hennerich
  Cc: andy, cosmin.tanislav, dlechner, jic23, lars, linusw, linux-iio,
	linux-kernel, nuno.sa, Wentao Liang, stable

The reference taken with iio_trigger_get() is only dropped by
iio_dev_release() when INDIO_BUFFER_TRIGGERED is set. Every failure
between trigger registration and the triggered buffer setup returns
before that mode is set and leaks the reference acquired for
indio_dev->trig. Move the iio_trigger_get() after the buffer setup
succeeds.

Fixes: fea251b6a5db ("iio: addac: add AD74413R driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/iio/addac/ad74413r.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
index fe930ce5ee30..380900bf6772 100644
--- a/drivers/iio/addac/ad74413r.c
+++ b/drivers/iio/addac/ad74413r.c
@@ -1397,7 +1397,6 @@ static int ad74413r_probe(struct spi_device *spi)
 	indio_dev->name = st->chip_info->name;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->info = &ad74413r_info;
-	indio_dev->trig = iio_trigger_get(st->trig);
 
 	ret = ad74413r_reset(st);
 	if (ret)
@@ -1467,6 +1466,8 @@ static int ad74413r_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
+	indio_dev->trig = iio_trigger_get(st->trig);
+
 	return devm_iio_device_register(st->dev, indio_dev);
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: addac: ad74413r: Fix trigger reference leak in ad74413r_probe()
  2026-09-16 16:22 [PATCH] iio: addac: ad74413r: Fix trigger reference leak in ad74413r_probe() Wentao Liang
@ 2026-09-17  0:28 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2026-09-17  0:28 UTC (permalink / raw)
  To: Wentao Liang
  Cc: Michael.Hennerich, andy, cosmin.tanislav, dlechner, lars, linusw,
	linux-iio, linux-kernel, nuno.sa, stable

On Wed, 16 Sep 2026 16:22:51 +0000
Wentao Liang <vulab@iscas.ac.cn> wrote:

> The reference taken with iio_trigger_get() is only dropped by
> iio_dev_release() when INDIO_BUFFER_TRIGGERED is set. Every failure
> between trigger registration and the triggered buffer setup returns
> before that mode is set and leaks the reference acquired for
> indio_dev->trig. Move the iio_trigger_get() after the buffer setup
> succeeds.
> 
> Fixes: fea251b6a5db ("iio: addac: add AD74413R driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Not this solution.  For anyone interested see other replies to similar patches.

> ---
>  drivers/iio/addac/ad74413r.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
> index fe930ce5ee30..380900bf6772 100644
> --- a/drivers/iio/addac/ad74413r.c
> +++ b/drivers/iio/addac/ad74413r.c
> @@ -1397,7 +1397,6 @@ static int ad74413r_probe(struct spi_device *spi)
>  	indio_dev->name = st->chip_info->name;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  	indio_dev->info = &ad74413r_info;
> -	indio_dev->trig = iio_trigger_get(st->trig);
>  
>  	ret = ad74413r_reset(st);
>  	if (ret)
> @@ -1467,6 +1466,8 @@ static int ad74413r_probe(struct spi_device *spi)
>  	if (ret)
>  		return ret;
>  
> +	indio_dev->trig = iio_trigger_get(st->trig);
> +
>  	return devm_iio_device_register(st->dev, indio_dev);
>  }
>  


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-17  0:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 16:22 [PATCH] iio: addac: ad74413r: Fix trigger reference leak in ad74413r_probe() Wentao Liang
2026-09-17  0:28 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®