[lxc-devel] [lxc/master] cgroups: prevent segfault

brauner on Github lxc-bot at linuxcontainers.org
Wed Jun 5 07:31:50 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190605/a7addd42/attachment.bin>
-------------- next part --------------
From dcd14a3db65bd07da96ee350bc2b575ad2737596 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 5 Jun 2019 09:27:45 +0200
Subject: [PATCH] cgroups: prevent segfault

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/cgroups/cgfsng.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index 5e5995f86c..9c05fbbe3d 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -453,8 +453,10 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
 		TRACE("The path \""__OFFLINE_CPUS"\" to read offline cpus from does not exist");
 	}
 
-	if ((maxisol == 0) && (maxoffline == 0))
+	if ((maxisol == 0) && (maxoffline == 0)) {
+		cpulist = move_ptr(posscpus);
 		goto copy_parent;
+	}
 
 	possmask = lxc_cpumask(posscpus, maxposs);
 	if (!possmask) {
@@ -506,8 +508,6 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
 		fpath = must_make_path(path, "cpuset.cpus", NULL);
 		ret = lxc_write_to_file(fpath, cpulist, strlen(cpulist), false,
 					0666);
-		if (cpulist == posscpus)
-			cpulist = NULL;
 		if (ret < 0) {
 			SYSERROR("Failed to write cpu list to \"%s\"", fpath);
 			return false;


More information about the lxc-devel mailing list