From 4e02d52ab9839ca3dc918362563ea407293dad58 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Wed, 7 Aug 2019 09:54:06 -0400 Subject: [PATCH] qemu: Fix possible NULL deref in qemuDomainGetResctrlMonData If virQEMUDriverGetCapabilities returns NULL, then a subsequent deref of @caps would cause an error, so we just return failure. Found by Coverity Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f1983f33e6..ff83d1c024 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20728,7 +20728,8 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driver, size_t i = 0; size_t j = 0; - caps = virQEMUDriverGetCapabilities(driver, false); + if (!(caps = virQEMUDriverGetCapabilities(driver, false))) + return -1; switch (tag) { case VIR_RESCTRL_MONITOR_TYPE_CACHE: -- GitLab