Module: xenomai-forge
Branch: master
Commit: b347afab3aca7d8a0c215f3b3b27a943f4f31726
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b347afab3aca7d8a0c215f3b3b27a943f4f31726

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Mon Nov 18 18:50:54 2013 +0100

cobalt/thread: clean up timers on __xnthread_init errors

Initializes timers may have been registered for statistical purposes, so
we must not leave them hanging around if __xnthread_init fails.

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

---

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

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index ed9937a..0b61380 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -197,14 +197,23 @@ int __xnthread_init(struct xnthread *thread,
        thread->init_schedparam = *sched_param;
        ret = xnsched_init_thread(thread);
        if (ret)
-               return ret;
+               goto err_out;
 
        ret = xnsched_set_policy(thread, sched_class, sched_param);
        if (ret)
-               return ret;
+               goto err_out;
 
-       if ((flags & (XNUSER|XNROOT)) == 0)
+       if ((flags & (XNUSER|XNROOT)) == 0) {
                ret = spawn_kthread(thread);
+               if (ret)
+                       goto err_out;
+       }
+
+       return 0;
+
+err_out:
+       xntimer_destroy(&thread->rtimer);
+       xntimer_destroy(&thread->ptimer);
 
        return ret;
 }


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

Reply via email to