ia64/xen-unstable

changeset 7695:913ad6d48cbc

Added some minor defensive coding/error handling in xc_linux_build.c
author mafetter@seana.research.intel-research.net
date Tue Nov 08 11:29:07 2005 +0100 (2005-11-08)
parents 889814fb94c5
children c4fc28fb580a
files tools/libxc/xc_linux_build.c
line diff
     1.1 --- a/tools/libxc/xc_linux_build.c	Mon Nov 07 18:35:55 2005 +0100
     1.2 +++ b/tools/libxc/xc_linux_build.c	Tue Nov 08 11:29:07 2005 +0100
     1.3 @@ -549,11 +549,10 @@ static int setup_guest(int xc_handle,
     1.4          rc = setup_pg_tables_pae(xc_handle, dom, ctxt,
     1.5                                   dsi.v_start, v_end,
     1.6                                   page_array, vpt_start, vpt_end);
     1.7 -    else {
     1.8 +    else
     1.9          rc = setup_pg_tables(xc_handle, dom, ctxt,
    1.10                               dsi.v_start, v_end,
    1.11                               page_array, vpt_start, vpt_end);
    1.12 -    }
    1.13  #endif
    1.14  #if defined(__x86_64__)
    1.15      rc = setup_pg_tables_64(xc_handle, dom, ctxt,
    1.16 @@ -671,8 +670,10 @@ static int setup_guest(int xc_handle,
    1.17      return 0;
    1.18  
    1.19   error_out:
    1.20 -    free(mmu);
    1.21 -    free(page_array);
    1.22 +    if ( mmu != NULL )
    1.23 +        free(mmu);
    1.24 +    if ( page_array != NULL )
    1.25 +        free(page_array);
    1.26      return -1;
    1.27  }
    1.28  #endif
    1.29 @@ -726,7 +727,7 @@ int xc_linux_build(int xc_handle,
    1.30  
    1.31      if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
    1.32      {   
    1.33 -        PERROR("xc_linux_build: ctxt mlock failed");
    1.34 +        PERROR("%s: ctxt mlock failed", __func__);
    1.35          return 1;
    1.36      }
    1.37  
    1.38 @@ -767,7 +768,8 @@ int xc_linux_build(int xc_handle,
    1.39          close(initrd_fd);
    1.40      if ( initrd_gfd )
    1.41          gzclose(initrd_gfd);
    1.42 -    free(image);
    1.43 +    if ( image != NULL )
    1.44 +        free(image);
    1.45  
    1.46  #ifdef __ia64__
    1.47      /* based on new_thread in xen/arch/ia64/domain.c */
    1.48 @@ -856,7 +858,8 @@ int xc_linux_build(int xc_handle,
    1.49          gzclose(initrd_gfd);
    1.50      else if ( initrd_fd >= 0 )
    1.51          close(initrd_fd);
    1.52 -    free(image);
    1.53 +    if ( image != NULL )
    1.54 +        free(image);
    1.55  
    1.56      return -1;
    1.57  }