From: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
"Maxime Ripard" <mripard@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
u.kleine-koenig@baylibre.com
Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Abdelnasser Hussein <abdelnasserhussein11@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v6 1/8] iio: adc: at91_adc: skip unpopulated triggers on teardown
Date: Thu, 03 Dec 2026 19:30:05 +0200 [thread overview]
Message-ID: <20261203-at91-adc-v6-v6-1-bfa754299f54@gmail.com> (raw)
In-Reply-To: <20261203-at91-adc-v6-v6-0-bfa754299f54@gmail.com>
at91_adc_trigger_init() and at91_adc_trigger_remove() iterate over all
st->trig entries. External trigger slots remain NULL when
"atmel,adc-use-external-triggers" is absent, so skip them in both
teardown loops.
Keep this as a minimal stable-backportable fix; the devm conversion later
in the series removes this teardown 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 | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 0ac74ad92fca..a4b1d08e8081 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -660,6 +660,13 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
error_trigger:
for (i--; i >= 0; i--) {
+ /*
+ * iio_trigger_unregister() is intentionally not NULL-aware so
+ * unregistering an unallocated trigger fails loudly.
+ */
+ if (!st->trig[i])
+ continue;
+
iio_trigger_unregister(st->trig[i]);
iio_trigger_free(st->trig[i]);
}
@@ -673,6 +680,13 @@ static void at91_adc_trigger_remove(struct iio_dev *idev)
int i;
for (i = 0; i < st->caps->trigger_number; i++) {
+ /*
+ * iio_trigger_unregister() is intentionally not NULL-aware so
+ * unregistering an unallocated trigger fails loudly.
+ */
+ if (!st->trig[i])
+ continue;
+
iio_trigger_unregister(st->trig[i]);
iio_trigger_free(st->trig[i]);
}
--
2.56.0
next prev parent reply other threads:[~2026-12-03 17:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:30 [PATCH v6 0/8] iio: adc: at91_adc: fix NULL trigger dereference and convert to devm Abdelnasser Hussein
2026-12-03 17:30 ` Abdelnasser Hussein [this message]
2026-12-03 17:53 ` [PATCH v6 1/8] iio: adc: at91_adc: skip unpopulated triggers on teardown Andy Shevchenko
2026-12-03 17:30 ` [PATCH v6 2/8] iio: adc: at91_adc: drop duplicate IRQ allocation error message Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 3/8] iio: adc: at91_adc: switch to device_get_match_data() Abdelnasser Hussein
2026-12-03 17:55 ` Andy Shevchenko
2026-12-03 17:30 ` [PATCH v6 4/8] iio: adc: at91_adc: convert to device_property_*() APIs Abdelnasser Hussein
2026-12-03 17:57 ` Andy Shevchenko
2026-12-03 17:30 ` [PATCH v6 5/8] iio: adc: at91_adc: use local struct device pointer in probe Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 6/8] iio: adc: at91_adc: pass struct device to at91_ts_register() Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 7/8] iio: adc: at91_adc: use HZ_PER_KHZ instead of raw 1000 Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 8/8] iio: adc: at91_adc: convert to device-managed resources Abdelnasser Hussein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203-at91-adc-v6-v6-1-bfa754299f54@gmail.com \
--to=abdelnasserhussein11@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andy@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=nuno.sa@analog.com \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®