From 4d902e1bb0858f94d8bb258fdc71751ee0c2fcbb Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sat, 9 Dec 2017 19:26:52 +0100 Subject: [PATCH] coverity: #1425866 free allocated memory Signed-off-by: Christian Brauner --- src/lxc/attach.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lxc/attach.c b/src/lxc/attach.c index b2ee12977..117d3418b 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -820,13 +820,17 @@ int lxc_attach(const char *name, const char *lxcpath, init_ctx->personality = personality; init_ctx->container = lxc_container_new(name, lxcpath); - if (!init_ctx->container) + if (!init_ctx->container) { + lxc_proc_put_context_info(init_ctx); return -1; + } if (!init_ctx->container->lxc_conf) { init_ctx->container->lxc_conf = lxc_conf_init(); - if (!init_ctx->container->lxc_conf) + if (!init_ctx->container->lxc_conf) { + lxc_proc_put_context_info(init_ctx); return -ENOMEM; + } } if (!fetch_seccomp(init_ctx->container, options)) @@ -1119,6 +1123,7 @@ int lxc_attach(const char *name, const char *lxcpath, if (ret <= 0) { ERROR("Expected to receive sequence number 0: %s.", strerror(errno)); shutdown(ipc_sockets[1], SHUT_RDWR); + lxc_proc_put_context_info(init_ctx); rexit(-1); } @@ -1129,6 +1134,7 @@ int lxc_attach(const char *name, const char *lxcpath, if (ret < 0) { ERROR("Failed to enter namespaces."); shutdown(ipc_sockets[1], SHUT_RDWR); + lxc_proc_put_context_info(init_ctx); rexit(-1); } /* close namespace file descriptors */ @@ -1167,6 +1173,7 @@ int lxc_attach(const char *name, const char *lxcpath, if (pid <= 0) { SYSERROR("Failed to create subprocess."); shutdown(ipc_sockets[1], SHUT_RDWR); + lxc_proc_put_context_info(init_ctx); rexit(-1); } @@ -1181,10 +1188,12 @@ int lxc_attach(const char *name, const char *lxcpath, */ ERROR("Intended to send pid %d: %s.", pid, strerror(errno)); shutdown(ipc_sockets[1], SHUT_RDWR); + lxc_proc_put_context_info(init_ctx); rexit(-1); } /* The rest is in the hands of the initial and the attached process. */ + lxc_proc_put_context_info(init_ctx); rexit(0); } -- 2.47.2