ia64/xen-unstable

changeset 7762:e436e4e93076

Add some minor defensive coding/error handling in xc_vmx_build.c like
C/S 7687

Signed-off-by: Haifeng Xue <haifeng.xue@intel.com>
Signed-off-by: Xin Li <xin.b.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Nov 10 12:06:50 2005 +0100 (2005-11-10)
parents bdb8c00ddb85
children de41f5e24cf1
files tools/libxc/xc_vmx_build.c
line diff
     1.1 --- a/tools/libxc/xc_vmx_build.c	Thu Nov 10 12:05:22 2005 +0100
     1.2 +++ b/tools/libxc/xc_vmx_build.c	Thu Nov 10 12:06:50 2005 +0100
     1.3 @@ -565,8 +565,10 @@ static int setup_guest(int xc_handle,
     1.4      return 0;
     1.5  
     1.6   error_out:
     1.7 -    free(mmu);
     1.8 -    free(page_array);
     1.9 +    if ( mmu != NULL )
    1.10 +        free(mmu);
    1.11 +    if ( page_array != NULL )
    1.12 +        free(page_array);
    1.13      return -1;
    1.14  }
    1.15  
    1.16 @@ -627,7 +629,7 @@ int xc_vmx_build(int xc_handle,
    1.17  
    1.18      if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
    1.19      {
    1.20 -        PERROR("xc_vmx_build: ctxt mlock failed");
    1.21 +        PERROR("%s: ctxt mlock failed", __func__);
    1.22          return 1;
    1.23      }
    1.24  
    1.25 @@ -661,7 +663,8 @@ int xc_vmx_build(int xc_handle,
    1.26          goto error_out;
    1.27      }
    1.28  
    1.29 -    free(image);
    1.30 +    if ( image != NULL )
    1.31 +        free(image);
    1.32  
    1.33      ctxt->flags = VGCF_VMX_GUEST;
    1.34      /* FPU is set up to default initial state. */
    1.35 @@ -707,7 +710,8 @@ int xc_vmx_build(int xc_handle,
    1.36      return rc;
    1.37  
    1.38   error_out:
    1.39 -    free(image);
    1.40 +    if ( image != NULL )
    1.41 +        free(image);
    1.42  
    1.43      return -1;
    1.44  }