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

[Xen-changelog] Added some minor defensive coding/error handling in xc_linux_build.c



# HG changeset patch
# User mafetter@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Node ID 913ad6d48cbc05638b46e3f86a835df7699d0750
# Parent  889814fb94c5cde86d56c18ea62957e8488219ba
Added some minor defensive coding/error handling in xc_linux_build.c

diff -r 889814fb94c5 -r 913ad6d48cbc tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Mon Nov  7 17:35:55 2005
+++ b/tools/libxc/xc_linux_build.c      Tue Nov  8 10:29:07 2005
@@ -549,11 +549,10 @@
         rc = setup_pg_tables_pae(xc_handle, dom, ctxt,
                                  dsi.v_start, v_end,
                                  page_array, vpt_start, vpt_end);
-    else {
+    else
         rc = setup_pg_tables(xc_handle, dom, ctxt,
                              dsi.v_start, v_end,
                              page_array, vpt_start, vpt_end);
-    }
 #endif
 #if defined(__x86_64__)
     rc = setup_pg_tables_64(xc_handle, dom, ctxt,
@@ -671,8 +670,10 @@
     return 0;
 
  error_out:
-    free(mmu);
-    free(page_array);
+    if ( mmu != NULL )
+        free(mmu);
+    if ( page_array != NULL )
+        free(page_array);
     return -1;
 }
 #endif
@@ -726,7 +727,7 @@
 
     if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
     {   
-        PERROR("xc_linux_build: ctxt mlock failed");
+        PERROR("%s: ctxt mlock failed", __func__);
         return 1;
     }
 
@@ -767,7 +768,8 @@
         close(initrd_fd);
     if ( initrd_gfd )
         gzclose(initrd_gfd);
-    free(image);
+    if ( image != NULL )
+        free(image);
 
 #ifdef __ia64__
     /* based on new_thread in xen/arch/ia64/domain.c */
@@ -856,7 +858,8 @@
         gzclose(initrd_gfd);
     else if ( initrd_fd >= 0 )
         close(initrd_fd);
-    free(image);
+    if ( image != NULL )
+        free(image);
 
     return -1;
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.