]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
process_utils: free stack after return
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 15 Apr 2021 12:11:56 +0000 (14:11 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 17 Apr 2021 15:26:30 +0000 (17:26 +0200)
Fixes: #3789
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/process_utils.c

index ccc4c0bf9860e1fbd9c9667b035ec3aa0d90431a..3dadeb7d7ae490191d65bc21cd5a0c8c6721f5fe 100644 (file)
@@ -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);