]> 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)
committerCole Robinson <crobinso@redhat.com>
Wed, 10 May 2017 19:30:16 +0000 (15:30 -0400)
On virGetInterface failure, call virInterfaceDefFree for the @def.

(cherry picked from commit 1b1b045915bec4cbc6ed087c96be4b1de8953002)

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++;