libvirt/libvirt-conf-fix-memory-leak-in-virNodeDevPCICapSRIOVVirtual.patch
2019-09-30 10:58:53 -04:00

33 lines
1.1 KiB
Diff

From 662ca668ba205216fe908eb5ab1816842625b83e Mon Sep 17 00:00:00 2001
From: Feng Ni <fengni@huawei.com>
Date: Thu, 25 Jul 2019 20:19:35 +0800
Subject: [PATCH] conf: fix memory leak in virNodeDevPCICapSRIOVVirtualParseXML
In function virNodeDevPCICapSRIOVVirtualParseXML, temp variable
addr could leak if VIR_APPEND_ELEMENT fails .
Signed-off-by: Feng Ni <fengni@huawei.com>
---
src/conf/node_device_conf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 0c804f5..1a8351e 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1519,8 +1519,10 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt,
if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions,
pci_dev->num_virtual_functions,
- addr) < 0)
+ addr) < 0) {
+ VIR_FREE(addr);
goto cleanup;
+ }
}
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
--
2.19.1