Module: xenomai-3
Branch: wip/dovetail
Commit: a4be282f12a2e3643362aa44791f6fbd6ff747a7
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a4be282f12a2e3643362aa44791f6fbd6ff747a7

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Jul 16 16:25:07 2016 +0200

cobalt/timer: guard against invalid calls to get_overruns()

Calculating the number of overruns only makes sense with active
periodic timers exclusively, which must have been requeued for the
next delivery already.

---

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

diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index 1c79013..3563636 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -593,6 +593,9 @@ unsigned long long xntimer_get_overruns(struct xntimer 
*timer, xnticks_t now)
        xnsticks_t delta;
        unsigned long long overruns = 0;
 
+       XENO_BUG_ON(COBALT, (timer->status &
+            (XNTIMER_DEQUEUED|XNTIMER_PERIODIC)) != XNTIMER_PERIODIC);
+       
        delta = now - xntimer_pexpect(timer);
        if (unlikely(delta >= (xnsticks_t) period)) {
                xntimerq_t *q;
@@ -604,8 +607,7 @@ unsigned long long xntimer_get_overruns(struct xntimer 
*timer, xnticks_t now)
 
                if (xntimer_running_p(timer)) {
                        q = xntimer_percpu_queue(timer);
-                       if ((timer->status & XNTIMER_DEQUEUED) == 0)
-                               xntimer_dequeue(timer, q);
+                       xntimer_dequeue(timer, q);
                        while (xntimerh_date(&timer->aplink) < now) {
                                timer->periodic_ticks++;
                                xntimer_update_date(timer);


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

Reply via email to