[libvirt] [PATCH] fix memleak in virNodeDeviceGetPCISRIOVCaps

From: Jiang Kun <jiang.kun2@zte.com.cn> it always alloc new memory when get dumpxml of pf device,but never free it. Now free the old first,then alloc new memory. Signed-off-by: Jiang kun <jiang.kun2@zte.com.cn> --- src/conf/node_device_conf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index e51371d..618ce8e 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; -- 1.8.3.1

On 9/12/19 10:05 AM, Yi Wang wrote:
From: Jiang Kun <jiang.kun2@zte.com.cn>
it always alloc new memory when get dumpxml of pf device,but never free it. Now free the old first,then alloc new memory.
Signed-off-by: Jiang kun <jiang.kun2@zte.com.cn> --- src/conf/node_device_conf.c | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and pushed. Congratulations Jiang on your first libvirt contribution. Michal
participants (2)
-
Michal Privoznik
-
Yi Wang