]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups: prevent segfault
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 5 Jun 2019 07:27:45 +0000 (09:27 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 13 Jun 2019 14:06:22 +0000 (16:06 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index abe9d3394749d259a232c3d1637d645dfcf182e1..631aaf11b4ef24a2c0bbfd8fc506ce961fd813dd 100644 (file)
@@ -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 @@ copy_parent:
                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;