diff options
author | 1996-06-20 10:53:06 +0000 | |
---|---|---|
committer | 1996-06-20 10:53:06 +0000 | |
commit | bd3f817612cf7396bb348de21cff17dfa4e5565a (patch) | |
tree | 06c25f8f427222a9e6150662592ecb5646a78d86 /sys/kern/kern_malloc.c | |
parent | tick v_swpin & v_swpout (diff) | |
download | wireguard-openbsd-bd3f817612cf7396bb348de21cff17dfa4e5565a.tar.xz wireguard-openbsd-bd3f817612cf7396bb348de21cff17dfa4e5565a.zip |
kern_malloc() can fail in canwait case if no more map space; return NULL in
that case so that callers can deal with shortage rather than deadlocking.
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r-- | sys/kern/kern_malloc.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index cee3073d782..dcbbcc32d3c 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1,5 +1,5 @@ -/* $OpenBSD: kern_malloc.c,v 1.5 1996/06/10 07:27:12 deraadt Exp $ */ -/* $NetBSD: kern_malloc.c,v 1.15.4.1 1996/06/06 19:14:30 cgd Exp $ */ +/* $OpenBSD: kern_malloc.c,v 1.6 1996/06/20 10:53:06 deraadt Exp $ */ +/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */ /* * Copyright (c) 1987, 1991, 1993 @@ -143,6 +143,16 @@ malloc(size, type, flags) va = (caddr_t) kmem_malloc(kmem_map, (vm_size_t)ctob(npg), !(flags & M_NOWAIT)); if (va == NULL) { + /* + * Kmem_malloc() can return NULL, even if it can + * wait, if there is no map space avaiable, because + * it can't fix that problem. Neither can we, + * right now. (We should release pages which + * are completely free and which are in buckets + * with too many free elements.) + */ + if ((flags & M_NOWAIT) == 0) + panic("malloc: out of space in kmem_map"); splx(s); return ((void *) NULL); } |