Commit 90e40bd3 authored by Yousong Zhou's avatar Yousong Zhou Committed by Jo-Philipp Wich

file: exec: properly free memory on error

Signed-off-by: default avatarYousong Zhou <yszhou4tech@gmail.com>
[fix whitespace]
Signed-off-by: default avatarJo-Philipp Wich <jo@mein.io>
parent 9ecfada1
......@@ -823,13 +823,16 @@ rpc_file_exec_run(const char *cmd, const struct blob_attr *sid,
if (!c)
return UBUS_STATUS_UNKNOWN_ERROR;
if (pipe(opipe) || pipe(epipe))
return rpc_errno_status();
if (pipe(opipe))
goto fail_opipe;
if (pipe(epipe))
goto fail_epipe;
switch ((pid = fork()))
{
case -1:
return rpc_errno_status();
goto fail_fork;
case 0:
uloop_done();
......@@ -921,6 +924,18 @@ rpc_file_exec_run(const char *cmd, const struct blob_attr *sid,
}
return UBUS_STATUS_OK;
fail_fork:
close(epipe[0]);
close(epipe[1]);
fail_epipe:
close(opipe[0]);
close(opipe[1]);
fail_opipe:
free(c);
return rpc_errno_status();
}
static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment