]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virNodeDevPCICapSRIOVVirtualParseXML: fix memleak of addr
authorHao Wang <wanghao232@huawei.com>
Thu, 30 Jul 2020 12:03:08 +0000 (20:03 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 30 Jul 2020 15:52:47 +0000 (17:52 +0200)
virPCIDeviceAddressPtr 'addr' is forgotten to be freed in the branch
'VIR_APPEND_ELEMENT() < 0'. Use g_autoptr instead.

Signed-off-by: Hao Wang <wanghao232@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/node_device_conf.c

index c54015336acce4379c9a461d3ff8ba91c2528a76..2f63772917d49c943f900495ecfb181c0874cb33 100644 (file)
@@ -1489,15 +1489,13 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt,
         goto cleanup;
 
     for (i = 0; i < naddresses; i++) {
-        virPCIDeviceAddressPtr addr = NULL;
+        g_autoptr(virPCIDeviceAddress) addr = NULL;
 
         if (VIR_ALLOC(addr) < 0)
             goto cleanup;
 
-        if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) {
-            VIR_FREE(addr);
+        if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0)
             goto cleanup;
-        }
 
         if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions,
                                pci_dev->num_virtual_functions,