[lxc-devel] [lxc/master] cgroup.c: fix memory leak at cgroup init failed

lifeng68 on Github lxc-bot at linuxcontainers.org
Tue Jan 14 07:55:52 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/20200113/ea7d116a/attachment.bin>
-------------- next part --------------
From e2a8c0c360d525d33ef15f1a88605234ff3daf7a Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68 at huawei.com>
Date: Tue, 14 Jan 2020 04:17:13 -0500
Subject: [PATCH] cgroup.c: fix memory leak at cgroup init failed

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

diff --git a/src/lxc/cgroups/cgroup.c b/src/lxc/cgroups/cgroup.c
index 11d14d27c4..2e9670e3b1 100644
--- a/src/lxc/cgroups/cgroup.c
+++ b/src/lxc/cgroups/cgroup.c
@@ -31,9 +31,11 @@ struct cgroup_ops *cgroup_init(struct lxc_conf *conf)
 	if (!cgroup_ops)
 		return log_error_errno(NULL, errno, "Failed to initialize cgroup driver");
 
-	if (cgroup_ops->data_init(cgroup_ops))
+	if (cgroup_ops->data_init(cgroup_ops)) {
+		cgroup_exit(cgroup_ops);
 		return log_error_errno(NULL, errno,
 				       "Failed to initialize cgroup data");
+	}
 
 	TRACE("Initialized cgroup driver %s", cgroup_ops->driver);
 


More information about the lxc-devel mailing list