From c2f6417bea7791ee5189626573a866585b66f6b5 Mon Sep 17 00:00:00 2001
From: Kaspar Schleiser <kaspar@schleiser.de>
Date: Wed, 7 Oct 2015 18:55:13 +0200
Subject: [PATCH] sys: xtimer: add another safeguard against setting a timer in
 the past

---
 sys/xtimer/xtimer_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys/xtimer/xtimer_core.c b/sys/xtimer/xtimer_core.c
index 97b336f0c4..92db65faab 100644
--- a/sys/xtimer/xtimer_core.c
+++ b/sys/xtimer/xtimer_core.c
@@ -482,6 +482,11 @@ overflow:
     if (timer_list_head) {
         /* schedule callback on next timer target time */
         next_target = timer_list_head->target - XTIMER_OVERHEAD;
+
+        /* make sure we're not setting a time in the past */
+        if (next_target < (_xtimer_now() + XTIMER_ISR_BACKOFF)) {
+            goto overflow;
+        }
     }
     else {
         /* there's no timer planned for this timer period */
-- 
GitLab