binfmt: Let binfmt_copyargv return error code

so the caller can distinguish the empty argument and out of memory quickly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2022-10-17 23:24:34 +08:00
committed by Masayuki Ishikawa
parent 774648de0f
commit 9f4bb7da97
3 changed files with 30 additions and 41 deletions
+11 -14
View File
@@ -142,26 +142,23 @@ int exec_module(FAR const struct binary_s *binp,
return -ENOMEM;
}
if (argv)
ret = binfmt_copyargv(&argv, argv);
if (ret < 0)
{
argv = binfmt_copyargv(argv);
if (!argv)
{
ret = -ENOMEM;
goto errout_with_tcb;
}
goto errout_with_tcb;
}
/* Make a copy of the environment here */
if (envp || (envp = environ))
if (envp == NULL)
{
envp = binfmt_copyenv(envp);
if (!envp)
{
ret = -ENOMEM;
goto errout_with_args;
}
envp = environ;
}
ret = binfmt_copyenv(&envp, envp);
if (ret < 0)
{
goto errout_with_args;
}
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)