[PATCH 05/10] iio: adc: stm32-adc: Detach chained IRQ handler before removing domain

From: Lee Jones

Date: Thu Nov 19 2026 - 10:33:17 EST


stm32_adc_irq_remove() disposes of the child IRQ mappings and removes
priv->domain before clearing the parent chained IRQ handlers. Because
the parent hardware interrupt lines remain unmasked while child devices
use dummy_irq_chip, an interrupt arriving during teardown invokes
stm32_adc_irq_handler() after irq_domain_remove() has freed
priv->domain, and irq_set_chained_handler() also leaves handler_data
dangling.

Detach the chained handlers and clear handler_data with
irq_set_chained_handler_and_data() before tearing down the mappings and
removing the domain.

Fixes: 1add69880240 ("iio: adc: Add support for STM32 ADC core")
Closes: https://sashiko.dev/#/bug/linux-27c38690-bc20-43aa-a3fc-1ddd6f1bb74e
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/iio/adc/stm32-adc-core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
index 4b532db3db62..13b75475046c 100644
--- a/drivers/iio/adc/stm32-adc-core.c
+++ b/drivers/iio/adc/stm32-adc-core.c
@@ -467,12 +467,12 @@ static void stm32_adc_irq_remove(struct platform_device *pdev,
int hwirq;
unsigned int i;

+ for (i = 0; i < priv->nb_irqs; i++)
+ irq_set_chained_handler_and_data(priv->irq[i], NULL, NULL);
+
for (hwirq = 0; hwirq < priv->nb_adc_max; hwirq++)
irq_dispose_mapping(irq_find_mapping(priv->domain, hwirq));
irq_domain_remove(priv->domain);
-
- for (i = 0; i < priv->nb_irqs; i++)
- irq_set_chained_handler(priv->irq[i], NULL);
}

static int stm32_adc_core_switches_supply_en(struct stm32_adc_priv *priv,
--
2.56.1.708.g77570a6a1d-goog