file: exec: properly free memory on error
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> [fix whitespace] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
9ecfada16d
commit
90e40bd3d5
1 changed files with 18 additions and 3 deletions
21
file.c
21
file.c
|
@ -823,13 +823,16 @@ rpc_file_exec_run(const char *cmd, const struct blob_attr *sid,
|
||||||
if (!c)
|
if (!c)
|
||||||
return UBUS_STATUS_UNKNOWN_ERROR;
|
return UBUS_STATUS_UNKNOWN_ERROR;
|
||||||
|
|
||||||
if (pipe(opipe) || pipe(epipe))
|
if (pipe(opipe))
|
||||||
return rpc_errno_status();
|
goto fail_opipe;
|
||||||
|
|
||||||
|
if (pipe(epipe))
|
||||||
|
goto fail_epipe;
|
||||||
|
|
||||||
switch ((pid = fork()))
|
switch ((pid = fork()))
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
return rpc_errno_status();
|
goto fail_fork;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
uloop_done();
|
uloop_done();
|
||||||
|
@ -921,6 +924,18 @@ rpc_file_exec_run(const char *cmd, const struct blob_attr *sid,
|
||||||
}
|
}
|
||||||
|
|
||||||
return UBUS_STATUS_OK;
|
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
|
static int
|
||||||
|
|
Loading…
Reference in a new issue