From: Jiang Kun Date: Thu, 12 Sep 2019 08:05:39 +0000 (+0800) Subject: node_device_conf: Don't leak @physical_function in virNodeDeviceGetPCISRIOVCaps X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=38816336a5026623d0a49988c6681b1323c79f09;p=libvirt.git node_device_conf: Don't leak @physical_function in virNodeDeviceGetPCISRIOVCaps 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 Reviewed-by: Michal Privoznik --- diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index e51371de89..618ce8e00e 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -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;