Module: xenomai-forge Branch: master Commit: fe5ed512876778fef7764f8ec777adfe4010a56f URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=fe5ed512876778fef7764f8ec777adfe4010a56f
Author: Philippe Gerum <[email protected]> Date: Wed Dec 14 15:36:51 2011 +0100 alchemy/task: fix unsafe threadobj call in rt_task_delete() --- lib/alchemy/task.c | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c index 9775dec..e21122e 100644 --- a/lib/alchemy/task.c +++ b/lib/alchemy/task.c @@ -327,6 +327,14 @@ int rt_task_delete(RT_TASK *task) COPPERPLATE_PROTECT(svc); + threadobj_lock(&tcb->thobj); + /* + * Prevent further reference to this zombie, including via + * alchemy_task_current(). + */ + threadobj_set_magic(&tcb->thobj, ~task_magic); + threadobj_unlock(&tcb->thobj); + if (syncobj_lock(&tcb->sobj_safe, &syns)) { ret = -EIDRM; goto out; @@ -343,16 +351,10 @@ int rt_task_delete(RT_TASK *task) } } - threadobj_lock(&tcb->thobj); - /* - * Prevent further reference to this zombie, including via - * alchemy_task_current(). - */ - threadobj_set_magic(&tcb->thobj, ~task_magic); - threadobj_unlock(&tcb->thobj); - syncobj_unlock(&tcb->sobj_safe, &syns); + threadobj_lock(&tcb->thobj); + ret = threadobj_cancel(&tcb->thobj); if (ret) ret = -EIDRM; @@ -408,7 +410,9 @@ int rt_task_shadow(RT_TASK *task, const char *name, int prio, int mode) if (ret) goto out; + threadobj_lock(&tcb->thobj); threadobj_start(&tcb->thobj); /* We won't wait in prologue. */ + threadobj_unlock(&tcb->thobj); ret = task_prologue(tcb); if (ret) { delete_tcb(tcb); _______________________________________________ Xenomai-git mailing list [email protected] https://mail.gna.org/listinfo/xenomai-git
