stm32: Detach GPIO IRQ callbacks upon clearing "setevent"

When the interrupts get disabled, the callback(s) are still attached.
That structure is never cleared, causing several calls to attach/detach
to eventually fail as the callback queue gets full.

When the error occurs, the registration fails with error 12 (ENOMEM).
By detaching the IRQ and clearing the callbacks, this error doesn't
happen again

Signed-off-by: Javier Alonso <javieralonso@geotab.com>
This commit is contained in:
Javier Alonso 2026-07-24 12:25:40 +02:00 committed by Alin Jerpelea
parent 10571e6d4c
commit cacf519a96

View file

@ -221,6 +221,7 @@ int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
xcpt_t handler;
int nshared;
int i;
int ret;
/* Select the interrupt handler for this EXTI pin */
@ -274,6 +275,16 @@ int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
if (i == nshared)
{
/* remove any leftover callback */
ret = irq_detach(irq);
if (ret < 0)
{
return ret;
}
/* disable the interrupt */
up_disable_irq(irq);
}
}