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

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

cobalt/kernel: 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 00d6c41..a6cb852 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