提交 38816336 编写于 作者: J Jiang Kun 提交者: Michal Privoznik

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: NJiang kun <jiang.kun2@zte.com.cn>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 4b3ab5d2
...@@ -2509,6 +2509,7 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath, ...@@ -2509,6 +2509,7 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath,
for (i = 0; i < pci_dev->num_virtual_functions; i++) for (i = 0; i < pci_dev->num_virtual_functions; i++)
VIR_FREE(pci_dev->virtual_functions[i]); VIR_FREE(pci_dev->virtual_functions[i]);
VIR_FREE(pci_dev->virtual_functions); VIR_FREE(pci_dev->virtual_functions);
VIR_FREE(pci_dev->physical_function);
pci_dev->num_virtual_functions = 0; pci_dev->num_virtual_functions = 0;
pci_dev->max_virtual_functions = 0; pci_dev->max_virtual_functions = 0;
pci_dev->flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; pci_dev->flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册