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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Apr 16 21:56:36 2017 +0200

cobalt/kernel: don't crash on early shadow mapping failure

This fixes a regression introduced by 203f200, trashing the global
thread list upon early failure in cobalt_map_user().

---

 kernel/cobalt/thread.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 34eca35..6a86265 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -203,6 +203,7 @@ int __xnthread_init(struct xnthread *thread,
        memset(&thread->stat, 0, sizeof(thread->stat));
        thread->selector = NULL;
        INIT_LIST_HEAD(&thread->claimq);
+       INIT_LIST_HEAD(&thread->glink);
        /* These will be filled by xnthread_start() */
        thread->entry = NULL;
        thread->cookie = NULL;
@@ -531,9 +532,11 @@ void __xnthread_discard(struct xnthread *thread)
        xntimer_destroy(&thread->ptimer);
 
        xnlock_get_irqsave(&nklock, s);
-       list_del(&thread->glink);
-       cobalt_nrthreads--;
-       xnvfile_touch_tag(&nkthreadlist_tag);
+       if (!list_empty(&thread->glink)) {
+               list_del(&thread->glink);
+               cobalt_nrthreads--;
+               xnvfile_touch_tag(&nkthreadlist_tag);
+       }
        xnthread_deregister(thread);
        xnlock_put_irqrestore(&nklock, s);
 }


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

Reply via email to