diff --git a/xen/common/gunzip.c b/xen/common/gunzip.c index db4efcd34b..425d64e904 100644 --- a/xen/common/gunzip.c +++ b/xen/common/gunzip.c @@ -114,11 +114,16 @@ __init int perform_gunzip(char *output, char *image, unsigned long image_len) window = (unsigned char *)output; free_mem_ptr = (unsigned long)alloc_xenheap_pages(HEAPORDER, 0); + if ( !free_mem_ptr ) + return -ENOMEM; + free_mem_end_ptr = free_mem_ptr + (PAGE_SIZE << HEAPORDER); + init_allocator(); inbuf = (unsigned char *)image; insize = image_len; inptr = 0; + bytes_out = 0; makecrc(); diff --git a/xen/common/inflate.c b/xen/common/inflate.c index f99c985d61..d8c28a3e95 100644 --- a/xen/common/inflate.c +++ b/xen/common/inflate.c @@ -238,6 +238,12 @@ STATIC const ush mask_bits[] = { static unsigned long INITDATA malloc_ptr; static int INITDATA malloc_count; +static void init_allocator(void) +{ + malloc_ptr = free_mem_ptr; + malloc_count = 0; +} + static void *INIT malloc(int size) { void *p;