From 431c1c05e6bb6f36f61e5f0acb8f68ef976cef70 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Thu, 15 Apr 2021 14:11:56 +0200 Subject: [PATCH] process_utils: free stack after return Fixes: #3789 Signed-off-by: Christian Brauner --- src/lxc/process_utils.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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); -- 2.47.3