Re: [libvirt] [PATCH] remote_driver.c: avoid leak on OOM error path

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

 



On Thu, Feb 11, 2010 at 12:58:54PM +0100, Jim Meyering wrote:
> Any "goto out_of_memory" taken between the vars = qparam_query_parse (query)
> allocation and the free_qparam_set call would result in a leak.
> 
> Here's the fix:
> 
> 
> >From a3a21142e40962c960eae882ac9edcc3bd17cb8b Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering@xxxxxxxxxx>
> Date: Thu, 11 Feb 2010 12:51:31 +0100
> Subject: [PATCH] remote_driver.c: avoid leak on OOM error path
> 
> * src/remote/remote_driver.c (doRemoteOpen): Don't leak a qparam_set
> buffer upon OOM error.
> ---
>  src/remote/remote_driver.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index e17db3d..cc543fc 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -2,7 +2,7 @@
>   * remote_internal.c: driver to provide access to libvirtd running
>   *   on a remote machine
>   *
> - * Copyright (C) 2007-2009 Red Hat, Inc.
> + * Copyright (C) 2007-2010 Red Hat, Inc.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
> @@ -370,6 +370,7 @@ doRemoteOpen (virConnectPtr conn,
>                virConnectAuthPtr auth ATTRIBUTE_UNUSED,
>                int flags)
>  {
> +    struct qparam_set *vars = NULL;
>      int wakeupFD[2] = { -1, -1 };
>      char *transport_str = NULL;
>      enum {
> @@ -458,7 +459,6 @@ doRemoteOpen (virConnectPtr conn,
>       * feasibly it might contain variables needed by the real driver,
>       * although that won't be the case for now).
>       */
> -    struct qparam_set *vars;
>      struct qparam *var;
>      int i;
>      char *query;
> @@ -551,6 +551,7 @@ doRemoteOpen (virConnectPtr conn,
>          }
> 
>          free_qparam_set (vars);
> +        vars = NULL;
>      } else {
>          /* Probe URI server side */
>          name = strdup("");
> @@ -933,6 +934,8 @@ doRemoteOpen (virConnectPtr conn,
> 
>   out_of_memory:
>      virReportOOMError();
> +    if (vars)
> +        free_qparam_set (vars);
> 
>   failed:
>      /* Close the socket if we failed. */

  ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]