[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] qemu: Check sev capability pointer before using it



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

Check sev capability pointer in function qemuGetSEVInfoToParams to avoid
null pointer dereferences.

Signed-off-by: Han Han <hhan redhat com>
---
 src/qemu/qemu_driver.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fb0d4a8c7a..3daaef586f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -21452,6 +21452,12 @@ qemuGetSEVInfoToParams(virQEMUCapsPtr qemuCaps,
 
     virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
 
+    if (!sev) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                       _("SEV is not supported in this guest"));
+        return -1;
+    }
+
     if (virTypedParamsAddString(&sevParams, &n, &maxpar,
                     VIR_NODE_SEV_PDH, sev->pdh) < 0)
         return -1;
-- 
2.18.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]