[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] qemu: Free previous error



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 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]