[libvirt] [PATCH 5/6] lxc: Avoid possible NULL dereference on *root prior to opendir().

John Ferlan jferlan at redhat.com
Mon Jan 7 17:09:33 UTC 2013


If running on older Linux without mounted cgroups then its possible that
*root would be NULL.
---
 src/lxc/lxc_container.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index d3a2968..d234426 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1762,6 +1762,12 @@ static int lxcContainerIdentifyCGroups(struct lxcContainerCGroup **mountsret,
         VIR_DEBUG("Grabbed '%s'", mntent.mnt_dir);
     }
 
+    if (!*root) {
+        VIR_DEBUG("No mounted cgroups found");
+        ret = 0;
+        goto cleanup;
+    }
+
     VIR_DEBUG("Checking for symlinks in %s", *root);
     if (!(dh = opendir(*root))) {
         virReportSystemError(errno,
-- 
1.7.11.7




More information about the libvir-list mailing list