[libvirt] [PATCH] interface: Fix resource leak in netcfConnectListAllInterfaces error path

Wang King king.wang at huawei.com
Wed Apr 12 07:58:23 UTC 2017


On virGetInterface failure, call virInterfaceDefFree for the @def.
---
 src/interface/interface_backend_netcf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index 700a8a0..c7cc071 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -622,8 +622,10 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
         }
 
         if (ifaces) {
-            if (!(iface_obj = virGetInterface(conn, def->name, def->mac)))
+            if (!(iface_obj = virGetInterface(conn, def->name, def->mac))) {
+                virInterfaceDefFree(def);
                 goto cleanup;
+            }
             tmp_iface_objs[niface_objs] = iface_obj;
         }
         niface_objs++;
-- 
2.8.3





More information about the libvir-list mailing list