]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Fix error path in virNodeDevPCICapabilityParseXML
authorJohn Ferlan <jferlan@redhat.com>
Thu, 5 May 2016 22:41:28 +0000 (18:41 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 9 May 2016 23:33:57 +0000 (19:33 -0400)
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 <jferlan@redhat.com>
src/conf/node_device_conf.c

index a06e4504285172d28b00c5c8548fc90f1c239d0c..aed95d56d0542038789714c70909869a8bea6a1c 100644 (file)
@@ -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,