]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc_cgroup: Add check for NULL cgroup before AddTask call
authorJohn Ferlan <jferlan@redhat.com>
Fri, 18 Dec 2015 13:25:47 +0000 (08:25 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 18 Dec 2015 13:59:34 +0000 (08:59 -0500)
Commit id '71ce4759' altered the cgroup processing with respect to the
call to virCgroupAddTask being moved out from lower layers into the calling
layers especially for qemu processing of emulator and vcpu threads. The
movement affected lxc insomuch as it is possible for a code path to
return a NULL cgroup *and* a 0 return status via virCgroupNewPartition
failure when virCgroupNewIgnoreError succeeded when virCgroupNewMachineManual
returns. Coverity pointed out that would cause virCgroupAddTask to core.

This patch will check for a NULL cgroup as well as the negative return
and just return the NULL cgroup to the caller (as it would have previously)

src/lxc/lxc_cgroup.c

index 609e9eafd883092434edc39a5c80b29029ff7e00..ef332e365865ba83cb96b181e627e7834bcbc708 100644 (file)
@@ -501,7 +501,7 @@ virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def,
                             nnicindexes, nicindexes,
                             def->resource->partition,
                             -1,
-                            &cgroup) < 0)
+                            &cgroup) < 0 || !cgroup)
         goto cleanup;
 
     if (virCgroupAddTask(cgroup, initpid) < 0) {