]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Check if kernel-provided info is consistent with itself
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 2 Feb 2018 14:05:22 +0000 (15:05 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 5 Feb 2018 12:33:13 +0000 (13:33 +0100)
Just in case someone re-mounted /sys/fs/resctrl with different mount
options (cdp), add a check here.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540780

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/util/virresctrl.c

index ef388757a704cd0d96550ef67abc6d0fae491dcf..6860e86e649d493b17e1f117b1469b2f2746d9c8 100644 (file)
@@ -941,6 +941,17 @@ virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl,
     if (!mask)
         return -1;
 
+    if (!resctrl ||
+        level >= resctrl->nlevels ||
+        !resctrl->levels[level] ||
+        !resctrl->levels[level]->types[type]) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Missing or inconsistent resctrl info for "
+                         "level '%ud' type '%s'"),
+                       level, virCacheTypeToString(type));
+        goto cleanup;
+    }
+
     if (virBitmapShrink(mask, resctrl->levels[level]->types[type]->bits) < 0)
         goto cleanup;