From: John Ferlan Date: Thu, 5 May 2016 22:41:28 +0000 (-0400) Subject: conf: Fix error path in virNodeDevPCICapabilityParseXML X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9d418b20ae060e6f69d942ab6a8ed85fd08d5d70;p=libvirt.git conf: Fix error path in virNodeDevPCICapabilityParseXML If the call to virXPathNodeSet to set naddresses fails, Coverity notes that the subsequent VIR_ALLOC_N cannot have a negative value (well it probably wouldn't be negative per se). Signed-off-by: John Ferlan --- diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index a06e450428..aed95d56d0 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1305,7 +1305,10 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, data->pci_dev.physical_function) < 0) goto out; } else if (STREQ(type, "virt_functions")) { - int naddresses = virXPathNodeSet("./address", ctxt, &addresses); + int naddresses; + + if ((naddresses = virXPathNodeSet("./address", ctxt, &addresses)) < 0) + goto out; if (maxFuncsStr && virStrToLong_uip(maxFuncsStr, NULL, 10,