[libvirt] [PATCH] fix memleak in virNodeDeviceGetPCISRIOVCaps

Yi Wang wang.yi59 at zte.com.cn
Thu Sep 12 08:05:39 UTC 2019


From: Jiang Kun <jiang.kun2 at 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 at 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




More information about the libvir-list mailing list