[libvirt] [PATCH 2/2] qemu: fix a mem leak

Chen Hanxiao posted 2 patches 7 years, 3 months ago
[libvirt] [PATCH 2/2] qemu: fix a mem leak
Posted by Chen Hanxiao 7 years, 3 months ago
From: Chen Hanxiao <chenhanxiao@gmail.com>

fix a mem leak

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
---
 src/qemu/qemu_driver.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5c55c69af..14b72a8f6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20682,6 +20682,8 @@ qemuARPGetInterfaces(virDomainObjPtr vm,
 
                 if (VIR_APPEND_ELEMENT(ifaces_ret, ifaces_count, iface) < 0)
                     goto cleanup;
+
+                virDomainInterfaceFree(iface);
             }
         }
     }
@@ -20691,6 +20693,7 @@ qemuARPGetInterfaces(virDomainObjPtr vm,
 
  cleanup:
     virArpTableFree(table);
+    virDomainInterfaceFree(iface);
 
     if (ifaces_ret) {
         for (i = 0; i < ifaces_count; i++)
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] qemu: fix a mem leak
Posted by Michal Privoznik 7 years, 3 months ago
On 03/17/2018 11:24 AM, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao@gmail.com>
> 
> fix a mem leak
> 
> Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
> ---
>  src/qemu/qemu_driver.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 5c55c69af..14b72a8f6 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -20682,6 +20682,8 @@ qemuARPGetInterfaces(virDomainObjPtr vm,
>  
>                  if (VIR_APPEND_ELEMENT(ifaces_ret, ifaces_count, iface) < 0)
>                      goto cleanup;
> +
> +                virDomainInterfaceFree(iface);

This makes no sense. In fact would be totally wrong if only
VIR_APPEND_ELEMENT wouldn't set iface = NULL on successful return.

>              }
>          }
>      }
> @@ -20691,6 +20693,7 @@ qemuARPGetInterfaces(virDomainObjPtr vm,
>  
>   cleanup:
>      virArpTableFree(table);
> +    virDomainInterfaceFree(iface);
>  
>      if (ifaces_ret) {
>          for (i = 0; i < ifaces_count; i++)
> 

ACK to this hunk though.

Michal

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