Module: xenomai-3
Branch: stable-3.0.x
Commit: 5b7be577beaad436a3c1d9b799f9b46e8747e04c
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5b7be577beaad436a3c1d9b799f9b46e8747e04c

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Wed Feb 24 21:44:41 2016 +0100

cobalt/timer: Make xntimer_get_overruns robust against stopped timers

xntimer_get_overruns might be called on meanwhile stopped timers,
specifically by cobalt_timer_deliver. We crash if we try to dequeue a
stopped timer, and we should not restart it as well.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 kernel/cobalt/timer.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index db6263d..3e85a53 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -602,13 +602,15 @@ unsigned long long xntimer_get_overruns(struct xntimer 
*timer, xnticks_t now)
                overruns = xnarch_div64(delta, period);
                timer->pexpect_ticks += overruns;
 
-               q = xntimer_percpu_queue(timer);
-               xntimer_dequeue(timer, q);
-               while (xntimerh_date(&timer->aplink) < now) {
-                       timer->periodic_ticks++;
-                       xntimer_update_date(timer);
+               if (xntimer_running_p(timer)) {
+                       q = xntimer_percpu_queue(timer);
+                       xntimer_dequeue(timer, q);
+                       while (xntimerh_date(&timer->aplink) < now) {
+                               timer->periodic_ticks++;
+                               xntimer_update_date(timer);
+                       }
+                       xntimer_enqueue_and_program(timer, q);
                }
-               xntimer_enqueue_and_program(timer, q);
        }
 
        timer->pexpect_ticks++;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to