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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Nov 18 15:36:27 2012 +0100

posix: avoid oops when pthread_set_name_np is called for non-posix thread

---

 ksrc/skins/posix/syscall.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/ksrc/skins/posix/syscall.c b/ksrc/skins/posix/syscall.c
index 9b1c266..6c78244 100644
--- a/ksrc/skins/posix/syscall.c
+++ b/ksrc/skins/posix/syscall.c
@@ -435,9 +435,11 @@ static int __pthread_set_name_np(struct pt_regs *regs)
        hkey.u_tid = __xn_reg_arg1(regs);
        hkey.mm = current->mm;
        k_tid = __pthread_find(&hkey);
-       p = xnthread_user_task(&k_tid->threadbase);
-       strncpy(p->comm, name, sizeof(p->comm));
-       p->comm[sizeof(p->comm) - 1] = '\0';
+       if (k_tid) {
+               p = xnthread_user_task(&k_tid->threadbase);
+               strncpy(p->comm, name, sizeof(p->comm));
+               p->comm[sizeof(p->comm) - 1] = '\0';
+       }
 
        return -pthread_set_name_np(k_tid, name);
 }


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

Reply via email to