diff options
author | Yousong Zhou <yszhou4tech@gmail.com> | 2019-10-21 12:59:23 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-05-26 16:21:13 +0200 |
commit | 7be1f17138f19d1d7a86e0c27b3662d3643ff296 (patch) | |
tree | 69db4831790e6edd014c5709376ca7ff4250f526 | |
parent | 313964caa8342a2f63258f2c98b714cd2de4fb52 (diff) | |
download | rpcd-7be1f17138f19d1d7a86e0c27b3662d3643ff296.tar.gz |
file: exec: properly free memory on erroropenwrt-18.06
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
[fix whitespace]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 90e40bd3d5b6d164be4c1f3583a13dc2f34d6563)
-rw-r--r-- | file.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -626,13 +626,16 @@ rpc_file_exec_run(const char *cmd, 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(); @@ -724,6 +727,18 @@ rpc_file_exec_run(const char *cmd, } 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 |