summaryrefslogtreecommitdiff
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2010-09-21 01:09:11 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2010-09-21 01:09:11 +0000
commitaec49b06efd518437143ea082ebc3444b205f905 (patch)
tree519a11628903805f9d127bb601f4e36b25cb8bd9 /sys/kern/kern_malloc.c
parent134cdfb67d09790ddb041cb0c8a22ddd7fc6e166 (diff)
Add assertwaitok(9) to declare code paths that assume they can sleep.
Currently only checks that we're not in an interrupt context, but will soon check that we're not holding any mutexes either. Update malloc(9) and pool(9) to use assertwaitok(9) as appropriate. "i like it" art@, oga@, marco@; "i see no harm" deraadt@; too trivial for me to bother prying actual oks from people.
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index e3bf091a885..986ec8f26d6 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.84 2010/07/22 06:30:13 matthew Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.85 2010/09/21 01:09:10 matthew Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -191,6 +191,9 @@ malloc(unsigned long size, int type, int flags)
panic("malloc - bogus type");
#endif
+ if ((flags & M_NOWAIT) == 0)
+ assertwaitok();
+
#ifdef MALLOC_DEBUG
if (debug_malloc(size, type, flags, (void **)&va)) {
if ((flags & M_ZERO) && va != NULL)