]> xenbits.xensource.com Git - libvirt.git/commitdiff
node_device_conf: Don't leak @physical_function in virNodeDeviceGetPCISRIOVCaps
authorJiang Kun <jiang.kun2@zte.com.cn>
Thu, 12 Sep 2019 08:05:39 +0000 (16:05 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 12 Sep 2019 14:17:35 +0000 (16:17 +0200)
The pci_dev->physical_function is rewritten in
virPCIGetPhysicalFunction() to a newly allocated pointer.
Therefore, we must free the old one to avoid memleak.

Signed-off-by: Jiang kun <jiang.kun2@zte.com.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/node_device_conf.c

index e51371de89e366cbdc6f37a6e73abfd6b9c21885..618ce8e00e5c974b993f5e1683971310134ff95b 100644 (file)
@@ -2509,6 +2509,7 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath,
     for (i = 0; i < pci_dev->num_virtual_functions; i++)
        VIR_FREE(pci_dev->virtual_functions[i]);
     VIR_FREE(pci_dev->virtual_functions);
+    VIR_FREE(pci_dev->physical_function);
     pci_dev->num_virtual_functions = 0;
     pci_dev->max_virtual_functions = 0;
     pci_dev->flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;