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

Wang King posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20170412075823.27384-1-king.wang@huawei.com
src/interface/interface_backend_netcf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[libvirt] [PATCH] interface: Fix resource leak in netcfConnectListAllInterfaces error path
Posted by Wang King 7 years ago
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


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] interface: Fix resource leak in netcfConnectListAllInterfaces error path
Posted by Peter Krempa 7 years ago
On Wed, Apr 12, 2017 at 15:58:23 +0800, Wang King wrote:
> On virGetInterface failure, call virInterfaceDefFree for the @def.
> ---
>  src/interface/interface_backend_netcf.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

ACK
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list