Module: xenomai-jki
Branch: for-forge
Commit: 02fcda4d4473f33a2cbd7cf94aced6f4d240f53f
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=02fcda4d4473f33a2cbd7cf94aced6f4d240f53f

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Mon Mar 16 18:09:33 2015 +0100

cobalt/sched-tp: Guard against multiple sched_declare calls

The sched_declare callback may also be invoked on threads that are
already in the tp class. In that case, avoid re-adding the thread to
tp.threads, corrupting the list this way.

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

---

 kernel/cobalt/sched-tp.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/sched-tp.c b/kernel/cobalt/sched-tp.c
index b088cf4..f9eaec7 100644
--- a/kernel/cobalt/sched-tp.c
+++ b/kernel/cobalt/sched-tp.c
@@ -166,7 +166,8 @@ static int xnsched_tp_declare(struct xnthread *thread,
            p->tp.prio > XNSCHED_TP_MAX_PRIO)
                return -EINVAL;
 
-       list_add_tail(&thread->tp_link, &sched->tp.threads);
+       if (thread->sched_class != &xnsched_class_tp)
+               list_add_tail(&thread->tp_link, &sched->tp.threads);
 
        return 0;
 }


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

Reply via email to