]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
interface: Fix resource leak in netcfConnectListAllInterfaces error path
authorWang King <king.wang@huawei.com>
Wed, 12 Apr 2017 07:58:23 +0000 (15:58 +0800)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 12 Apr 2017 08:38:24 +0000 (10:38 +0200)
On virGetInterface failure, call virInterfaceDefFree for the @def.

src/interface/interface_backend_netcf.c

index 700a8a075c39146268ebfcdee82c74721816fff5..c7cc07122abef44f5ca5ad436e894917789b4ef2 100644 (file)
@@ -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++;