[libvirt] [PATCH] qemu: Free previous error

virCopyLastError simply overwrites destination, which may lead to leak if there already was error. Therefore we need first to free destination. --- src/qemu/qemu_migration.c | 1 + src/qemu/qemu_monitor.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3e4f4fe..56dd26b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1586,6 +1586,7 @@ static void qemuMigrationIOFunc(void *arg) return; error: + virResetError(&data->err); virCopyLastError(&data->err); virResetLastError(); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 8573262..66a4e48 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -603,6 +603,7 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque) { if (!err) qemuReportError(VIR_ERR_INTERNAL_ERROR, _("Error while processing monitor IO")); + virResetError(&mon->lastError); virCopyLastError(&mon->lastError); virResetLastError(); } -- 1.7.5.rc3

Caller must free returned value of virXPathString --- src/conf/domain_conf.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2315c98..05c9d3e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5732,6 +5732,7 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, } else { def->os.bios.useserial = VIR_DOMAIN_BIOS_USESERIAL_NO; } + VIR_FREE(useserial); } *bootCount = deviceBoot; -- 1.7.5.rc3

On Mon, Jul 11, 2011 at 07:02:36PM +0200, Michal Privoznik wrote:
Caller must free returned value of virXPathString --- src/conf/domain_conf.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2315c98..05c9d3e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5732,6 +5732,7 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, } else { def->os.bios.useserial = VIR_DOMAIN_BIOS_USESERIAL_NO; } + VIR_FREE(useserial); }
*bootCount = deviceBoot;
ACK and pushed, thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Mon, Jul 11, 2011 at 07:02:35PM +0200, Michal Privoznik wrote:
virCopyLastError simply overwrites destination, which may lead to leak if there already was error. Therefore we need first to free destination. --- src/qemu/qemu_migration.c | 1 + src/qemu/qemu_monitor.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3e4f4fe..56dd26b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1586,6 +1586,7 @@ static void qemuMigrationIOFunc(void *arg) return;
error: + virResetError(&data->err); virCopyLastError(&data->err); virResetLastError(); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 8573262..66a4e48 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -603,6 +603,7 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque) { if (!err) qemuReportError(VIR_ERR_INTERNAL_ERROR, _("Error while processing monitor IO")); + virResetError(&mon->lastError); virCopyLastError(&mon->lastError); virResetLastError(); }
NACK, neither of these are required. There is only one place in qemuMigrationIOFunc which sets data->err and that is the one you're modifying. So it is impossible for data->err to have an existing error. The code changed in qemuMonitorIO has already validated that mon->lastError is not set in an if(...) that the diff here doesn't show. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Michal Privoznik