Instead of panicing when no page can be allocated try to fail the
memory allocation by returning NULL instead.
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
if (new_brk > heap_mapped) {
unsigned long n = (new_brk - heap_mapped + PAGE_SIZE - 1) / PAGE_SIZE;
+
+ if ( n > nr_free_pages )
+ {
+ printk("Memory exhausted: want %ld pages, but only %ld are left\n",
+ n, nr_free_pages);
+ return NULL;
+ }
do_map_zero(heap_mapped, n);
heap_mapped += n * PAGE_SIZE;
}