Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v5 1/8] iio: adc: at91_adc: skip unpopulated triggers on teardown
       [not found] <20261123070101.53868-1-abdelnasserhussein11@gmail.com>
@ 2026-11-23  7:00 ` Abdelnasser Hussein
  2026-11-23  7:53   ` Joshua Crofts
  0 siblings, 1 reply; 2+ messages in thread
From: Abdelnasser Hussein @ 2026-11-23  7:00 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: dlechner, nuno.sa, andy, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, giorgitchankvetadze1997, amin.gattout,
	antoniu.miclaus, gregkh, mripard, linux-arm-kernel, linux-kernel,
	Abdelnasser Hussein, stable

The driver keeps an array of triggers and leaves the slots for external
triggers unpopulated (NULL) when the "atmel,adc-use-external-triggers"
property is not set.  Both the error rollback path in
at91_adc_trigger_init() and at91_adc_trigger_remove() walk the whole
array and call iio_trigger_unregister() and iio_trigger_free() on every
entry, including the empty ones, which dereferences NULL.

Skip unpopulated trigger slots in both loops.

Make a minimal fix to simplify backporting. Moving over to device managed
cleanup will shortly remove this code.

Fixes: 0e589d5fb317 ("ARM: AT91: IIO: Add AT91 ADC driver.")
Cc: stable@vger.kernel.org
Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
---
 drivers/iio/adc/at91_adc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 0ac74ad92fca..9ecf8ca362f5 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -660,6 +660,9 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
 
 error_trigger:
 	for (i--; i >= 0; i--) {
+		if (!st->trig[i])
+			continue;
+
 		iio_trigger_unregister(st->trig[i]);
 		iio_trigger_free(st->trig[i]);
 	}
@@ -673,6 +676,9 @@ static void at91_adc_trigger_remove(struct iio_dev *idev)
 	int i;
 
 	for (i = 0; i < st->caps->trigger_number; i++) {
+		if (!st->trig[i])
+			continue;
+
 		iio_trigger_unregister(st->trig[i]);
 		iio_trigger_free(st->trig[i]);
 	}
-- 
2.56.0


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

* Re: [PATCH v5 1/8] iio: adc: at91_adc: skip unpopulated triggers on teardown
  2026-11-23  7:00 ` [PATCH v5 1/8] iio: adc: at91_adc: skip unpopulated triggers on teardown Abdelnasser Hussein
@ 2026-11-23  7:53   ` Joshua Crofts
  0 siblings, 0 replies; 2+ messages in thread
From: Joshua Crofts @ 2026-11-23  7:53 UTC (permalink / raw)
  To: Abdelnasser Hussein, jic23, linux-iio
  Cc: dlechner, nuno.sa, andy, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, giorgitchankvetadze1997, amin.gattout,
	antoniu.miclaus, gregkh, mripard, linux-arm-kernel, linux-kernel,
	stable

On 23-Nov-26 8:00, Abdelnasser Hussein wrote:
> The driver keeps an array of triggers and leaves the slots for external
> triggers unpopulated (NULL) when the "atmel,adc-use-external-triggers"
> property is not set.  Both the error rollback path in
> at91_adc_trigger_init() and at91_adc_trigger_remove() walk the whole
> array and call iio_trigger_unregister() and iio_trigger_free() on every
> entry, including the empty ones, which dereferences NULL.
> 
> Skip unpopulated trigger slots in both loops.
> 
> Make a minimal fix to simplify backporting. Moving over to device managed
> cleanup will shortly remove this code.
> 
> Fixes: 0e589d5fb317 ("ARM: AT91: IIO: Add AT91 ADC driver.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
> ---
Reviewed-by: Joshua Crofts <crofts@kernel.org>

-- 
Kind regards,
Joshua Crofts


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

end of thread, other threads:[~2026-11-23  7:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261123070101.53868-1-abdelnasserhussein11@gmail.com>
2026-11-23  7:00 ` [PATCH v5 1/8] iio: adc: at91_adc: skip unpopulated triggers on teardown Abdelnasser Hussein
2026-11-23  7:53   ` Joshua Crofts

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