]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virNodeDeviceDefParse: Don't call post-parse callbacks with NULL def
authorPeter Krempa <pkrempa@redhat.com>
Mon, 18 Oct 2021 07:54:08 +0000 (09:54 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 18 Oct 2021 15:40:46 +0000 (17:40 +0200)
When parsing of the node device XML fails we'd still call the post-parse
and validation callbacks which makes no sense. Additionally the
callbacks were expecting a non-NULL pointer which leads to a crash.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2014139
Fixes: d5ae634ba28
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/conf/node_device_conf.c

index 9bbff97ffdde784e529b272a0fd1805cdecbc0f1..1f39e2cbfd46dd6dc5c66bfa6c9e062bde35af7d 100644 (file)
@@ -2177,10 +2177,10 @@ virNodeDeviceDefParse(const char *str,
     g_autoptr(xmlDoc) xml = NULL;
     g_autoptr(virNodeDeviceDef) def = NULL;
 
-    if ((xml = virXMLParse(filename, str, _("(node_device_definition)"), NULL, false))) {
-        def = virNodeDeviceDefParseNode(xml, xmlDocGetRootElement(xml),
-                                        create, virt_type);
-    }
+    if (!(xml = virXMLParse(filename, str, _("(node_device_definition)"), NULL, false)) ||
+        !(def = virNodeDeviceDefParseNode(xml, xmlDocGetRootElement(xml),
+                                          create, virt_type)))
+        return NULL;
 
     if (parserCallbacks) {
         int ret = 0;