summaryrefslogtreecommitdiff
path: root/nuttx/binfmt/binfmt_execmodule.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-14 14:10:23 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-14 14:10:23 -0600
commit8a1169b515470b959633c5fba69a135d7789a96f (patch)
tree8139f7e3d309f54efd53b89610417d3abc2cbd89 /nuttx/binfmt/binfmt_execmodule.c
parent60b7d076c27f4e3450d9beb7131adf787411f529 (diff)
downloadnuttx-8a1169b515470b959633c5fba69a135d7789a96f.tar.gz
nuttx-8a1169b515470b959633c5fba69a135d7789a96f.tar.bz2
nuttx-8a1169b515470b959633c5fba69a135d7789a96f.zip
In kernel mode, we have to duplicate the callers argv[] buffer when exec'ing new tasks. When the argv[] buffer is needed, the caller's address environment will not longer be in place
Diffstat (limited to 'nuttx/binfmt/binfmt_execmodule.c')
-rw-r--r--nuttx/binfmt/binfmt_execmodule.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c
index dae892571..f2ff5db7a 100644
--- a/nuttx/binfmt/binfmt_execmodule.c
+++ b/nuttx/binfmt/binfmt_execmodule.c
@@ -192,7 +192,7 @@ int exec_module(FAR const struct binary_s *binp)
if (!stack)
{
err = ENOMEM;
- goto errout_with_kstack;
+ goto errout_with_addrenv;
}
/* Initialize the task */
@@ -203,9 +203,13 @@ int exec_module(FAR const struct binary_s *binp)
{
err = get_errno();
bdbg("task_init() failed: %d\n", err);
- goto errout_with_kstack;
+ goto errout_with_addrenv;
}
+ /* We can free the argument buffer now */
+
+ binfmt_freeargv(binp);
+
/* Note that tcb->flags are not modified. 0=normal task */
/* tcb->flags |= TCB_FLAG_TTYPE_TASK; */
@@ -217,7 +221,7 @@ int exec_module(FAR const struct binary_s *binp)
{
bdbg("ERROR: up_addrenv_select() failed: %d\n", ret);
err = -ret;
- goto errout_with_addrenv;
+ goto errout_with_tcbinit;
}
#endif
@@ -292,12 +296,7 @@ errout_with_tcbinit:
kumm_free(stack);
goto errout;
-errout_with_kstack:
-#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
- (void)up_addrenv_kstackfree(tcb);
-
errout_with_addrenv:
-#endif
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
(void)up_addrenv_restore(&oldenv);