summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2003-12-28 16:35:46 +0000
committertedu <tedu@openbsd.org>2003-12-28 16:35:46 +0000
commitd0977410e3134afe80da18a3f956a1d49ff0d80d (patch)
tree8405ee651290e019af7fee52cb51ad11513af4f6 /sys/kern/kern_malloc.c
parentfixes from wiz@netbsd; (diff)
downloadwireguard-openbsd-d0977410e3134afe80da18a3f956a1d49ff0d80d.tar.xz
wireguard-openbsd-d0977410e3134afe80da18a3f956a1d49ff0d80d.zip
make check for too large allocations earlier, instead of fiddling with it.
less error prone (no wraparound). no real functional change though. ok markus tdeval
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 5fce2f4ea8c..082a7b2d764 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.55 2003/07/21 22:44:50 tedu Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.56 2003/12/28 16:35:46 tedu Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -151,6 +151,8 @@ malloc(size, type, flags)
return ((void *) va);
#endif
+ if (size > 65535 * PAGE_SIZE)
+ panic("malloc: allocation too large");
indx = BUCKETINDX(size);
kbp = &bucket[indx];
s = splvm();
@@ -199,8 +201,6 @@ malloc(size, type, flags)
kup = btokup(va);
kup->ku_indx = indx;
if (allocsize > MAXALLOCSAVE) {
- if (npg > 65535)
- panic("malloc: allocation too large");
kup->ku_pagecnt = npg;
#ifdef KMEMSTATS
ksp->ks_memuse += allocsize;