exti: return error when double adding or removing chained isrs
Calling extiChainIsr twice with no extiUnchainIsr in between would
corrupt the shared isr list.
Bug: 31653505
Change-Id: I3c4b852e6d815545ccf49602b8770d162a791d60
Signed-off-by: Ben Fennema <fennema@google.com>
diff --git a/firmware/src/platform/stm32f4xx/exti.c b/firmware/src/platform/stm32f4xx/exti.c
index 2543ac2..5d5cb4b 100644
--- a/firmware/src/platform/stm32f4xx/exti.c
+++ b/firmware/src/platform/stm32f4xx/exti.c
@@ -186,6 +186,8 @@
struct ExtiInterrupt *exti = extiForIrq(n);
if (!exti)
return -EINVAL;
+ else if (!list_is_empty(&isr->node))
+ return -EINVAL;
chainIsr(&exti->base, isr);
if (!mMaxLatency || (isr->maxLatencyNs && isr->maxLatencyNs < mMaxLatency))
@@ -199,6 +201,8 @@
struct ExtiInterrupt *exti = extiForIrq(n);
if (!exti)
return -EINVAL;
+ else if (list_is_empty(&isr->node))
+ return -EINVAL;
unchainIsr(&exti->base, isr);
if (isr->maxLatencyNs && isr->maxLatencyNs == mMaxLatency)