[lxc-devel] [lxc/master] cgfsng.c: fix memeory leaks

lifeng68 on Github lxc-bot at linuxcontainers.org
Wed Jan 15 01:48:00 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 344 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200114/202f4436/attachment.bin>
-------------- next part --------------
From c86a3f79cc925c17d18a82aabb8d06e6e4f258af Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68 at huawei.com>
Date: Tue, 14 Jan 2020 22:08:07 -0500
Subject: [PATCH] cgfsng.c: fix memeory leaks

Signed-off-by: LiFeng <lifeng68 at huawei.com>
---
 src/lxc/cgroups/cgfsng.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index 9751fb7612..4d6d74129b 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -3000,8 +3000,11 @@ static int cg_hybrid_init(struct cgroup_ops *ops, bool relative, bool unprivileg
 		return log_error_errno(-1, errno, "Failed to retrieve available legacy cgroup controllers");
 
 	f = fopen("/proc/self/mountinfo", "r");
-	if (!f)
+	if (!f) {
+		free_string_list(klist);
+		free_string_list(nlist);
 		return log_error_errno(-1, errno, "Failed to open \"/proc/self/mountinfo\"");
+	}
 
 	lxc_cgfsng_print_basecg_debuginfo(basecginfo, klist, nlist);
 


More information about the lxc-devel mailing list