[libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths and qemuMonitorJSONAttachCharDevCommand

Yi Wang posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1495847450-48620-1-git-send-email-wang.yi59@zte.com.cn
daemon/libvirtd.c            | 1 +
src/qemu/qemu_monitor_json.c | 2 ++
2 files changed, 3 insertions(+)
[libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths and qemuMonitorJSONAttachCharDevCommand
Posted by Yi Wang 6 years, 11 months ago
From: Xi Xu <xu.xi8@zte.com.cn>

The @rundir is allocated in virGetUserRuntimeDirectory, may lost
when virFileMakePath failed.

The tlsalias allocated in qemuAliasTLSObjFromSrcAlias may lost
when append string to json.
---
 daemon/libvirtd.c            | 1 +
 src/qemu/qemu_monitor_json.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 891238b..2447d78 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -288,6 +288,7 @@ daemonUnixSocketPaths(struct daemonConfig *config,
             old_umask = umask(077);
             if (virFileMakePath(rundir) < 0) {
                 umask(old_umask);
+                VIR_FREE(rundir);
                 goto error;
             }
             umask(old_umask);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 0837290..66f3f87 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6481,6 +6481,8 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
 
             if (virJSONValueObjectAppendString(data, "tls-creds", tlsalias) < 0)
                 goto error;
+
+            VIR_FREE(tlsalias);
         }
         break;
 
-- 
1.8.3.1


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths and qemuMonitorJSONAttachCharDevCommand
Posted by Peter Krempa 6 years, 11 months ago
On Fri, May 26, 2017 at 21:10:50 -0400, Yi Wang wrote:
> From: Xi Xu <xu.xi8@zte.com.cn>
> 
> The @rundir is allocated in virGetUserRuntimeDirectory, may lost
> when virFileMakePath failed.
> 
> The tlsalias allocated in qemuAliasTLSObjFromSrcAlias may lost
> when append string to json.

Those are two separate changes in two separate sections of the code.
Please send separate patches for them.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list