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

Re: [libvirt] [PATCH] esx_vmx.c: don't dereference a NULL virtualDev



On Tue, Dec 15, 2009 at 04:09:06PM +0100, Jim Meyering wrote:
> The offending code starts here:
> 
> int
> esxVMX_ParseSCSIController(virConnectPtr conn, virConfPtr conf, int controller,
>                            int *present, char **virtualDev)
> {
>     char present_name[32];
>     char virtualDev_name[32];
> 
>     if (virtualDev == NULL || *virtualDev != NULL) {
>         ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
>         goto failure;
>     }
> 
> If the virtualDev parameter is NULL, then we'd issue the
> diagnostic and take the "goto", and (below), dereference NULL.
> 
> >From 79283ba1d667534175d4c48079e6b500feba6480 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering redhat com>
> Date: Tue, 15 Dec 2009 16:07:10 +0100
> Subject: [PATCH] esx_vmx.c: don't dereference NULL for a NULL virtualDev
> 
> * src/esx/esx_vmx.c (esxVMX_ParseSCSIController): Don't deref
> "virtualDev" when it is NULL.
> ---
>  src/esx/esx_vmx.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
> index f5b4544..404617e 100644
> --- a/src/esx/esx_vmx.c
> +++ b/src/esx/esx_vmx.c
> @@ -1204,7 +1204,8 @@ esxVMX_ParseSCSIController(virConnectPtr conn, virConfPtr conf, int controller,
>      return 0;
> 
>    failure:
> -    VIR_FREE(*virtualDev);
> +    if (virtualDev)
> +        VIR_FREE(*virtualDev);
> 
>      return -1;
>  }

ACK !

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/


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