projects
/
project
/
rpcd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5cd4f4e
)
exec: properly free memory on rpc_exec() error
author
Yousong Zhou
<yszhou4tech@gmail.com>
Mon, 21 Oct 2019 06:10:27 +0000
(06:10 +0000)
committer
Jo-Philipp Wich
<jo@mein.io>
Tue, 26 May 2020 14:18:26 +0000
(16:18 +0200)
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
[fix whitespace]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit
02c6e1d08c9abfebae050ebeab5766935e849dc2
)
exec.c
patch
|
blob
|
history
plugin.c
patch
|
blob
|
history
diff --git
a/exec.c
b/exec.c
index eb529664a6ad98457892d1d800d9e4ff2676943c..f490ad7c11bd89644f617533cd1ead0aa65b6e03 100644
(file)
--- a/
exec.c
+++ b/
exec.c
@@
-313,7
+313,7
@@
rpc_exec(const char **args, rpc_exec_write_cb_t in,
switch ((pid = fork()))
{
case -1:
-
return rpc_errno_status()
;
+
goto fail_fork
;
case 0:
uloop_done();
@@
-372,6
+372,10
@@
rpc_exec(const char **args, rpc_exec_write_cb_t in,
return UBUS_STATUS_OK;
+fail_fork:
+ close(epipe[0]);
+ close(epipe[1]);
+
fail_epipe:
close(opipe[0]);
close(opipe[1]);
@@
-381,5
+385,6
@@
fail_opipe:
close(ipipe[1]);
fail_ipipe:
+ free(c);
return rpc_errno_status();
}
diff --git
a/plugin.c
b/plugin.c
index 877345d7a9a635efb94f7e5e5ff223731c274176..bf7c74db5d5253d4f5f6a6971e3dd9b55f36c6a8 100644
(file)
--- a/
plugin.c
+++ b/
plugin.c
@@
-161,9
+161,12
@@
rpc_plugin_call(struct ubus_context *ctx, struct ubus_object *obj,
c->argv[1] = "call";
c->argv[2] = c->method;
- return rpc_exec(c->argv, rpc_plugin_call_stdin_cb,
- rpc_plugin_call_stdout_cb, rpc_plugin_call_stderr_cb,
- rpc_plugin_call_finish_cb, c, ctx, req);
+ rv = rpc_exec(c->argv, rpc_plugin_call_stdin_cb,
+ rpc_plugin_call_stdout_cb, rpc_plugin_call_stderr_cb,
+ rpc_plugin_call_finish_cb, c, ctx, req);
+
+ if (rv == UBUS_STATUS_OK)
+ return rv;
fail:
if (c)