[libvirt] [PATCH 14/14] hyperv: Address resource leak found by Coverityo

Matthias Bolte matthias.bolte at googlemail.com
Thu Jan 10 15:50:26 UTC 2013


2013/1/9 John Ferlan <jferlan at redhat.com>:
> Because result was used to determine whether or not to free 'priv'
> resources Coverity tagged the code as having a resource leak. This
> change addresses that concern.
> ---
>  src/hyperv/hyperv_driver.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index 601a85a..e69a232 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -121,6 +121,7 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
>          virReportOOMError();
>          goto cleanup;
>      }
> +    conn->privateData = priv;
>
>      if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) {
>          goto cleanup;
> @@ -199,18 +200,17 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
>          goto cleanup;
>      }
>
> -    conn->privateData = priv;
> -
>      result = VIR_DRV_OPEN_SUCCESS;
>
>    cleanup:
> -    if (result == VIR_DRV_OPEN_ERROR) {
> -        hypervFreePrivate(&priv);
> -    }
> +    if (result == VIR_DRV_OPEN_ERROR)
> +        conn->privateData = NULL;
>
>      VIR_FREE(username);
>      VIR_FREE(password);
>      hypervFreeObject(priv, (hypervObject *)computerSystem);
> +    if (priv && !conn->privateData)
> +        hypervFreePrivate(&priv);
>
>      return result;
>  }

The same comment as for the ESX driver in this series applies here.

I'll come up with a patch for this later today.

-- 
Matthias Bolte
http://photron.blogspot.com




More information about the libvir-list mailing list