9119d9
From da1cfc045a9ac338983e33e0906d9065a7ab9343 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <da1cfc045a9ac338983e33e0906d9065a7ab9343@dist-git>
9119d9
From: Martin Kletzander <mkletzan@redhat.com>
9119d9
Date: Thu, 15 Jan 2015 15:03:50 +0100
9119d9
Subject: [PATCH] util: Fix possible NULL dereference
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1161540
9119d9
9119d9
Commit 1a80b97d, which added the virCgroupHasEmptyTasks() function
9119d9
forgot that the parameter @cgroup may be NULL and did not check that.
9119d9
9119d9
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9119d9
(cherry picked from commit 3b0f05573fbf385cca554d3383fad0089ed080cf)
9119d9
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/util/vircgroup.c | 3 +++
9119d9
 1 file changed, 3 insertions(+)
9119d9
9119d9
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
9119d9
index dbe7ee7..5df3d7a 100644
9119d9
--- a/src/util/vircgroup.c
9119d9
+++ b/src/util/vircgroup.c
9119d9
@@ -3921,6 +3921,9 @@ virCgroupHasEmptyTasks(virCgroupPtr cgroup, int controller)
9119d9
     int ret = -1;
9119d9
     char *content = NULL;
9119d9
 
9119d9
+    if (!cgroup)
9119d9
+        return -1;
9119d9
+
9119d9
     ret = virCgroupGetValueStr(cgroup, controller, "tasks", &content);
9119d9
 
9119d9
     if (ret == 0 && content[0] == '\0')
9119d9
-- 
9119d9
2.2.1
9119d9