]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
minios: Fix xfree() bug.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 2 Apr 2008 14:32:13 +0000 (15:32 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 2 Apr 2008 14:32:13 +0000 (15:32 +0100)
It has to check first if the memory to free is so big as to be freed
directly by free_pages. mini-os domains crash without this patch if
vfb is misconfigured.

Signed-off-by: INAKOSHI Hiroya <inakoshi.hiroya@jp.fujitsu.com>
lib/xmalloc.c

index d4c3941738167992434da2528f7d1e966843edb1..82d5cc61db4f4bb286e8d8c68eb1a735a5a783be 100644 (file)
@@ -208,6 +208,13 @@ void xfree(const void *p)
     pad = (struct xmalloc_pad *)p - 1;
     hdr = (struct xmalloc_hdr *)((char *)p - pad->hdr_size);
 
+    /* Big allocs free directly. */
+    if ( hdr->size >= PAGE_SIZE )
+    {
+        free_pages(hdr, get_order(hdr->size));
+        return;
+    }
+
     /* We know hdr will be on same page. */
     if(((long)p & PAGE_MASK) != ((long)hdr & PAGE_MASK))
     {
@@ -222,13 +229,6 @@ void xfree(const void *p)
         *(int*)0=0;
     }
 
-    /* Big allocs free directly. */
-    if ( hdr->size >= PAGE_SIZE )
-    {
-        free_pages(hdr, get_order(hdr->size));
-        return;
-    }
-
     /* Merge with other free block, or put in list. */
     /* spin_lock_irqsave(&freelist_lock, flags); */
     list_for_each_entry_safe( i, tmp, &freelist, freelist )