ia64/xen-unstable

changeset 17376:6c83e17c6e89

minios: Fix xfree() bug.

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>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 02 15:32:13 2008 +0100 (2008-04-02)
parents b89a5d046aa7
children d48551c66377
files extras/mini-os/lib/xmalloc.c
line diff
     1.1 --- a/extras/mini-os/lib/xmalloc.c	Wed Apr 02 15:30:26 2008 +0100
     1.2 +++ b/extras/mini-os/lib/xmalloc.c	Wed Apr 02 15:32:13 2008 +0100
     1.3 @@ -208,6 +208,13 @@ void xfree(const void *p)
     1.4      pad = (struct xmalloc_pad *)p - 1;
     1.5      hdr = (struct xmalloc_hdr *)((char *)p - pad->hdr_size);
     1.6  
     1.7 +    /* Big allocs free directly. */
     1.8 +    if ( hdr->size >= PAGE_SIZE )
     1.9 +    {
    1.10 +        free_pages(hdr, get_order(hdr->size));
    1.11 +        return;
    1.12 +    }
    1.13 +
    1.14      /* We know hdr will be on same page. */
    1.15      if(((long)p & PAGE_MASK) != ((long)hdr & PAGE_MASK))
    1.16      {
    1.17 @@ -222,13 +229,6 @@ void xfree(const void *p)
    1.18          *(int*)0=0;
    1.19      }
    1.20  
    1.21 -    /* Big allocs free directly. */
    1.22 -    if ( hdr->size >= PAGE_SIZE )
    1.23 -    {
    1.24 -        free_pages(hdr, get_order(hdr->size));
    1.25 -        return;
    1.26 -    }
    1.27 -
    1.28      /* Merge with other free block, or put in list. */
    1.29      /* spin_lock_irqsave(&freelist_lock, flags); */
    1.30      list_for_each_entry_safe( i, tmp, &freelist, freelist )