Re: [libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths
On Tue, Jun 13, 2017 at 03:06:14PM +0200, Michal Privoznik wrote: > On 06/13/2017 03:05 PM, Erik Skultety wrote: > > On Tue, Jun 13, 2017 at 01:55:24PM +0200, Michal Privoznik wrote: > >> On 06/13/2017 11:02 AM, Erik Skultety wrote: > >>> On Mon, Jun 12, 2017 at 02:02:20AM -0400, Yi Wang wrote: > The @rundir is allocated in virGetUserRuntimeDirectory, may lost > when virFileMakePath failed. > >>> > >>> ACK. I slightly reworded the commit message and pushed. > >>> > >> > >> Funny, I have a similar patch on my branch: > >> > >> https://github.com/zippy2/libvirt/commit/3c00409576f7b6158935baba7ff8059f66a1dd3b > >> > >> How about instead of putting VIR_FREE() at each exit path, we have just > >> one exit path (= use more gotos) and have VIR_FREE() just once. > > > > I wanted to suggest that, but I didn't apply the "generic" rule, rather I > > judged the function as an individual, it's not a monster function, the > > variable > > is used just in the block, so I was OK with that as it was. Of course, your > > approach works just as well, it's just a few more lines of code. If you feel > > like doing it, I have nothing against. > > Actually, it's less lines of code than what we currently have. I'll post > the patch shortly. Aha, my bad, I meant a bigger diff, bad wording, sorry, of course the resulting number of lines will be smaller. :) Erik > > Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths
On 06/13/2017 03:05 PM, Erik Skultety wrote: > On Tue, Jun 13, 2017 at 01:55:24PM +0200, Michal Privoznik wrote: >> On 06/13/2017 11:02 AM, Erik Skultety wrote: >>> On Mon, Jun 12, 2017 at 02:02:20AM -0400, Yi Wang wrote: The @rundir is allocated in virGetUserRuntimeDirectory, may lost when virFileMakePath failed. >>> >>> ACK. I slightly reworded the commit message and pushed. >>> >> >> Funny, I have a similar patch on my branch: >> >> https://github.com/zippy2/libvirt/commit/3c00409576f7b6158935baba7ff8059f66a1dd3b >> >> How about instead of putting VIR_FREE() at each exit path, we have just >> one exit path (= use more gotos) and have VIR_FREE() just once. > > I wanted to suggest that, but I didn't apply the "generic" rule, rather I > judged the function as an individual, it's not a monster function, the > variable > is used just in the block, so I was OK with that as it was. Of course, your > approach works just as well, it's just a few more lines of code. If you feel > like doing it, I have nothing against. Actually, it's less lines of code than what we currently have. I'll post the patch shortly. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths
On Tue, Jun 13, 2017 at 01:55:24PM +0200, Michal Privoznik wrote: > On 06/13/2017 11:02 AM, Erik Skultety wrote: > > On Mon, Jun 12, 2017 at 02:02:20AM -0400, Yi Wang wrote: > >> The @rundir is allocated in virGetUserRuntimeDirectory, may lost > >> when virFileMakePath failed. > > > > ACK. I slightly reworded the commit message and pushed. > > > > Funny, I have a similar patch on my branch: > > https://github.com/zippy2/libvirt/commit/3c00409576f7b6158935baba7ff8059f66a1dd3b > > How about instead of putting VIR_FREE() at each exit path, we have just > one exit path (= use more gotos) and have VIR_FREE() just once. I wanted to suggest that, but I didn't apply the "generic" rule, rather I judged the function as an individual, it's not a monster function, the variable is used just in the block, so I was OK with that as it was. Of course, your approach works just as well, it's just a few more lines of code. If you feel like doing it, I have nothing against. Erik > > Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths
On 06/13/2017 11:02 AM, Erik Skultety wrote: > On Mon, Jun 12, 2017 at 02:02:20AM -0400, Yi Wang wrote: >> The @rundir is allocated in virGetUserRuntimeDirectory, may lost >> when virFileMakePath failed. > > ACK. I slightly reworded the commit message and pushed. > Funny, I have a similar patch on my branch: https://github.com/zippy2/libvirt/commit/3c00409576f7b6158935baba7ff8059f66a1dd3b How about instead of putting VIR_FREE() at each exit path, we have just one exit path (= use more gotos) and have VIR_FREE() just once. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths
On Mon, Jun 12, 2017 at 02:02:20AM -0400, Yi Wang wrote: > The @rundir is allocated in virGetUserRuntimeDirectory, may lost > when virFileMakePath failed. ACK. I slightly reworded the commit message and pushed. Thanks, Erik -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths
The @rundir is allocated in virGetUserRuntimeDirectory, may lost when virFileMakePath failed. Signed-off-by: Xi Xu--- daemon/libvirtd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index bac4bc1..d17a694 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); -- 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
On Fri, May 26, 2017 at 21:10:50 -0400, Yi Wang wrote: > From: Xi Xu> > 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. signature.asc Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] fix memory leak in daemonUnixSocketPaths and qemuMonitorJSONAttachCharDevCommand
From: Xi XuThe @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