From: Peter Krempa Date: Mon, 18 Oct 2021 07:54:08 +0000 (+0200) Subject: virNodeDeviceDefParse: Don't call post-parse callbacks with NULL def X-Git-Tag: v7.9.0-rc1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8eb08e0fc5fe42efd2b0a4226f2b71f183ba193b;p=thirdparty%2Flibvirt.git virNodeDeviceDefParse: Don't call post-parse callbacks with NULL def 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 Reviewed-by: Erik Skultety --- diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 9bbff97ffd..1f39e2cbfd 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -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;