* [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