[PATCH] qemuMonitorFdsetsFree: Don't leak @set->fds

Michal Privoznik posted 1 patch 2 weeks, 4 days ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/975c793c1420899db8f4f358341a035e1bbeb1cb.1610028357.git.mprivozn@redhat.com
src/qemu/qemu_monitor.c | 2 ++
1 file changed, 2 insertions(+)

[PATCH] qemuMonitorFdsetsFree: Don't leak @set->fds

Posted by Michal Privoznik 2 weeks, 4 days ago
The @fds member of qemuMonitorFdsetInfo struct is an array and as
such, it's allocated in qemuMonitorJSONQueryFdsetsParse() but not
freed in qemuMonitorFdsetsFree().

Fixes: b8998cc670f7b1b11a83276050e49dce7efba333
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_monitor.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 40f2997cb6..abdd9d5240 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2708,6 +2708,8 @@ void qemuMonitorFdsetsFree(qemuMonitorFdsetsPtr fdsets)
 
         for (j = 0; j < set->nfds; j++)
             g_free(set->fds[j].opaque);
+
+        g_free(set->fds);
     }
     g_free(fdsets->fdsets);
     g_free(fdsets);
-- 
2.26.2

Re: [PATCH] qemuMonitorFdsetsFree: Don't leak @set->fds

Posted by Daniel P. Berrangé 2 weeks, 4 days ago
On Thu, Jan 07, 2021 at 03:05:57PM +0100, Michal Privoznik wrote:
> The @fds member of qemuMonitorFdsetInfo struct is an array and as
> such, it's allocated in qemuMonitorJSONQueryFdsetsParse() but not
> freed in qemuMonitorFdsetsFree().
> 
> Fixes: b8998cc670f7b1b11a83276050e49dce7efba333
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_monitor.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index 40f2997cb6..abdd9d5240 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -2708,6 +2708,8 @@ void qemuMonitorFdsetsFree(qemuMonitorFdsetsPtr fdsets)
>  
>          for (j = 0; j < set->nfds; j++)
>              g_free(set->fds[j].opaque);
> +
> +        g_free(set->fds);
>      }
>      g_free(fdsets->fdsets);
>      g_free(fdsets);

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|