[lxc-devel] [lxc/master] Revert "nl: fix memory leak"

brauner on Github lxc-bot at linuxcontainers.org
Thu Jun 18 08:29:49 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 534 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200618/a3d13e0c/attachment.bin>
-------------- next part --------------
From 6a5f8648410106dbe614362e001fd1394d744c58 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 18 Jun 2020 10:28:35 +0200
Subject: [PATCH] Revert "nl: fix memory leak"

This was an obvious braino on my part to merge this. Out automatic cleanup
macros will handle this case just fine so this introduces a double-free. Rever
this commit.

This reverts commit 9d05339487f4e9c4e7f700f963c161a4d9977ae4.
---
 src/lxc/nl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/lxc/nl.c b/src/lxc/nl.c
index 048a5a53f1..dd94c09c88 100644
--- a/src/lxc/nl.c
+++ b/src/lxc/nl.c
@@ -106,10 +106,8 @@ struct nlmsg *nlmsg_alloc(size_t size)
 		return ret_set_errno(NULL, ENOMEM);
 
 	nlmsg->nlmsghdr = malloc(len);
-	if (!nlmsg->nlmsghdr) {
-		free(nlmsg);
+	if (!nlmsg->nlmsghdr)
 		return ret_set_errno(NULL, ENOMEM);
-	}
 
 	memset(nlmsg->nlmsghdr, 0, len);
 	nlmsg->cap = len;


More information about the lxc-devel mailing list