diff --git a/sched/task/task_fork.c b/sched/task/task_fork.c index 964c55b0395..359db312f48 100644 --- a/sched/task/task_fork.c +++ b/sched/task/task_fork.c @@ -221,14 +221,6 @@ FAR struct tcb_s *nxtask_setup_fork(start_t retaddr) } #endif - /* Setup thread local storage */ - - ret = tls_dup_info(child, parent); - if (ret < OK) - { - goto errout_with_tcb; - } - /* Get the priority of the parent task */ #ifdef CONFIG_PRIORITY_INHERITANCE @@ -247,6 +239,14 @@ FAR struct tcb_s *nxtask_setup_fork(start_t retaddr) goto errout_with_tcb; } + /* Setup thread local storage */ + + ret = tls_dup_info(child, parent); + if (ret < OK) + { + goto errout_with_tcb; + } + /* Setup to pass parameters to the new task */ ret = nxtask_setup_stackargs(child, argv[0], &argv[1]);