From: Christian Brauner Date: Thu, 15 Apr 2021 12:11:56 +0000 (+0200) Subject: process_utils: free stack after return X-Git-Tag: lxc-5.0.0~202^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=431c1c05e6bb6f36f61e5f0acb8f68ef976cef70;p=thirdparty%2Flxc.git process_utils: free stack after return Fixes: #3789 Signed-off-by: Christian Brauner --- diff --git a/src/lxc/process_utils.c b/src/lxc/process_utils.c index ccc4c0bf9..3dadeb7d7 100644 --- a/src/lxc/process_utils.c +++ b/src/lxc/process_utils.c @@ -146,14 +146,12 @@ int lxc_raw_pidfd_send_signal(int pidfd, int sig, siginfo_t *info, #define __LXC_STACK_SIZE (8 * 1024 * 1024) pid_t lxc_clone(int (*fn)(void *), void *arg, int flags, int *pidfd) { + __do_free void *stack = NULL; pid_t ret; - void *stack; stack = malloc(__LXC_STACK_SIZE); - if (!stack) { - SYSERROR("Failed to allocate clone stack"); - return -ENOMEM; - } + if (!stack) + return syserror_set(-ENOMEM, "Failed to allocate clone stack"); #ifdef __ia64__ ret = __clone2(fn, stack, __LXC_STACK_SIZE, flags | SIGCHLD, arg, pidfd);