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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Jun 14 12:40:55 2013 +0200

kernel/cobalt: fix potential race in pthread_set_name_np()

---

 kernel/cobalt/thread.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 6f202e9..840baab 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -965,19 +965,22 @@ int cobalt_thread_set_name_np(unsigned long tid, const 
char __user *u_name)
        hkey.mm = current->mm;
 
        xnlock_get_irqsave(&nklock, s);
+
        pthread = thread_find(&hkey);
        if (pthread == NULL) {
                xnlock_put_irqrestore(&nklock, s);
                return -ESRCH;
        }
 
+       snprintf(xnthread_name(&pthread->threadbase),
+                XNOBJECT_NAME_LEN - 1, "%s", name);
        p = xnthread_host_task(&pthread->threadbase);
        get_task_struct(p);
+
        xnlock_put_irqrestore(&nklock, s);
+
        strncpy(p->comm, name, sizeof(p->comm));
        p->comm[sizeof(p->comm) - 1] = '\0';
-       snprintf(xnthread_name(&pthread->threadbase),
-                XNOBJECT_NAME_LEN - 1, "%s", name);
        put_task_struct(p);
 
        return 0;


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

Reply via email to