summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2006-11-22 18:59:51 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2006-11-22 18:59:51 +0000
commita9a1f643dd1cfcc12d8e25f1bfeb9dafc0bc9d53 (patch)
tree496fdea676a40719efd0e9761b147ae7c0c4df9f
parent31c3926b5efa5f5e76032c21af9584271bb133e9 (diff)
If M_CANFAIL is set and the malloc() size is to big
return NULL instead of panic()'ing. ok pedro@, deraadt@
-rw-r--r--sys/kern/kern_malloc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 040ea782114..3652ec639d3 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.63 2006/09/30 14:31:28 mickey Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.64 2006/11/22 18:59:50 thib Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -151,8 +151,13 @@ malloc(unsigned long size, int type, int flags)
return ((void *) va);
#endif
- if (size > 65535 * PAGE_SIZE)
- panic("malloc: allocation too large");
+ if (size > 65535 * PAGE_SIZE) {
+ if (flags & M_CANFAIL)
+ return (NULL);
+ else
+ panic("malloc: allocation too large");
+ }
+
indx = BUCKETINDX(size);
kbp = &bucket[indx];
s = splvm();