summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-20 10:53:10 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-20 10:53:10 +0000
commit1e818041a24e6002c9ec32181f7670b29bdc323b (patch)
tree1be89419fabb6a14ba780bfde5a677dd7729769c /sys
parent0b9eff8105b4d1b4eadc8fd665d40dd6c8f6f36a (diff)
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')
-rw-r--r--sys/kern/kern_malloc.c14
-rw-r--r--sys/vm/vm_kern.c13
2 files changed, 21 insertions, 6 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);
}
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c
index 5b578fa3238..c5475f0d1f8 100644
--- a/sys/vm/vm_kern.c
+++ b/sys/vm/vm_kern.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_kern.c,v 1.17 1995/04/10 16:53:55 mycroft Exp $ */
+/* $NetBSD: vm_kern.c,v 1.17.6.1 1996/06/13 17:21:28 cgd Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -297,9 +297,14 @@ kmem_malloc(map, size, canwait)
vm_map_lock(map);
if (vm_map_findspace(map, 0, size, &addr)) {
vm_map_unlock(map);
- if (canwait) /* XXX should wait */
- panic("kmem_malloc: %s too small",
- map == kmem_map ? "kmem_map" : "mb_map");
+ /*
+ * Should wait, but that makes no sense since we will
+ * likely never wake up unless action to free resources
+ * is taken by the calling subsystem.
+ *
+ * We return NULL, and if the caller was able to wait
+ * then they should take corrective action and retry.
+ */
return (0);
}
offset = addr - vm_map_min(kmem_map);