Module: xenomai-gch Branch: for-forge Commit: 6eed1aaf43c3bedc17f84f11117b55792784a8e7 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=6eed1aaf43c3bedc17f84f11117b55792784a8e7
Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org> Date: Tue Oct 8 22:29:30 2013 +0200 switchtest: do not pass arguments to kernel tasks on caller stack --- kernel/drivers/testing/switchtest.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/drivers/testing/switchtest.c b/kernel/drivers/testing/switchtest.c index ea36ee6..a9fa87b 100644 --- a/kernel/drivers/testing/switchtest.c +++ b/kernel/drivers/testing/switchtest.c @@ -396,6 +396,8 @@ static void rtswitch_ktask(void *cookie) rtswitch_context_t *ctx = arg->ctx; rtswitch_task_t *task = arg->task; + xnfree(arg); + to = task->base.index; rtswitch_pend_rt(ctx, task->base.index); @@ -448,7 +450,7 @@ static int rtswitch_create_ktask(rtswitch_context_t *ctx, struct xnthread_start_attr sattr; struct xnthread_init_attr iattr; rtswitch_task_t *task; - struct taskarg arg; + struct taskarg *arg; int init_flags; char name[30]; int err; @@ -472,8 +474,9 @@ static int rtswitch_create_ktask(rtswitch_context_t *ctx, task = &ctx->tasks[ptask->index]; - arg.ctx = ctx; - arg.task = task; + arg = xnmalloc(sizeof(*arg)); + arg->ctx = ctx; + arg->task = task; init_flags = (ptask->flags & RTTST_SWTEST_FPU) ? XNFPU : 0; @@ -488,7 +491,7 @@ static int rtswitch_create_ktask(rtswitch_context_t *ctx, if (!err) { sattr.mode = 0; sattr.entry = rtswitch_ktask; - sattr.cookie = &arg; + sattr.cookie = arg; err = xnthread_start(&task->ktask, &sattr); } else /* @@ -496,11 +499,6 @@ static int rtswitch_create_ktask(rtswitch_context_t *ctx, * invalid thread. */ task->base.flags = 0; - /* - * Putting the argument on stack is safe, because the new - * thread will preempt the current thread immediately, and - * will suspend only once the arguments on stack are used. - */ return err; } _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git