patch-2.4.21 linux-2.4.21/mm/vmalloc.c

Next file: linux-2.4.21/net/802/Makefile
Previous file: linux-2.4.21/mm/swapfile.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/mm/vmalloc.c linux-2.4.21/mm/vmalloc.c
@@ -170,7 +170,7 @@
 
 struct vm_struct * get_vm_area(unsigned long size, unsigned long flags)
 {
-	unsigned long addr;
+	unsigned long addr, next;
 	struct vm_struct **p, *tmp, *area;
 
 	area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
@@ -190,7 +190,9 @@
 			goto out;
 		if (size + addr <= (unsigned long) tmp->addr)
 			break;
-		addr = tmp->size + (unsigned long) tmp->addr;
+		next = tmp->size + (unsigned long) tmp->addr;
+		if (next > addr) 
+			addr = next;
 		if (addr > VMALLOC_END-size)
 			goto out;
 	}
@@ -238,10 +240,8 @@
 	struct vm_struct *area;
 
 	size = PAGE_ALIGN(size);
-	if (!size || (size >> PAGE_SHIFT) > num_physpages) {
-		BUG();
+	if (!size || (size >> PAGE_SHIFT) > num_physpages)
 		return NULL;
-	}
 	area = get_vm_area(size, VM_ALLOC);
 	if (!area)
 		return NULL;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)