404507
From e3521dc836329e941d3d7bea0bcac1b0731162a5 Mon Sep 17 00:00:00 2001
404507
Message-Id: <e3521dc836329e941d3d7bea0bcac1b0731162a5@dist-git>
404507
From: Martin Kletzander <mkletzan@redhat.com>
404507
Date: Mon, 5 Feb 2018 13:39:19 +0100
404507
Subject: [PATCH] util: Check if kernel-provided info is consistent with itself
404507
404507
Just in case someone re-mounted /sys/fs/resctrl with different mount
404507
options (cdp), add a check here.
404507
404507
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540780
404507
404507
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
404507
(cherry picked from commit d300b5448721970962efc18c3b3b0a358f2359ab)
404507
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
404507
---
404507
 src/util/virresctrl.c | 11 +++++++++++
404507
 1 file changed, 11 insertions(+)
404507
404507
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
404507
index ef388757a7..6860e86e64 100644
404507
--- a/src/util/virresctrl.c
404507
+++ b/src/util/virresctrl.c
404507
@@ -941,6 +941,17 @@ virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl,
404507
     if (!mask)
404507
         return -1;
404507
 
404507
+    if (!resctrl ||
404507
+        level >= resctrl->nlevels ||
404507
+        !resctrl->levels[level] ||
404507
+        !resctrl->levels[level]->types[type]) {
404507
+        virReportError(VIR_ERR_INTERNAL_ERROR,
404507
+                       _("Missing or inconsistent resctrl info for "
404507
+                         "level '%ud' type '%s'"),
404507
+                       level, virCacheTypeToString(type));
404507
+        goto cleanup;
404507
+    }
404507
+
404507
     if (virBitmapShrink(mask, resctrl->levels[level]->types[type]->bits) < 0)
404507
         goto cleanup;
404507
 
404507
-- 
404507
2.16.1
404507