diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2014-01-23 01:48:45 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2014-01-23 01:48:45 +0000 |
commit | f9438c0d64089f2ba777bd20df336dc92f42e624 (patch) | |
tree | c896277289bca7143dbdca86b687fe7dea72b187 /sys | |
parent | ff6f27f968c3314d57e925b9c002c1c9b4344fda (diff) |
msleep() with a NULL mtx argument is a programming error.
ok matthew@ phessler@ dlg@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_synch.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index e268d107e44..50b3a851deb 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.113 2014/01/23 00:33:36 guenther Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.114 2014/01/23 01:48:44 guenther Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -154,32 +154,30 @@ msleep(const volatile void *ident, struct mutex *mtx, int priority, int error, error1, spl; KASSERT((priority & ~(PRIMASK | PCATCH | PNORELOCK)) == 0); + KASSERT(mtx != NULL); sleep_setup(&sls, ident, priority, wmesg); sleep_setup_timeout(&sls, timo); sleep_setup_signal(&sls, priority); - if (mtx) { - /* XXX - We need to make sure that the mutex doesn't - * unblock splsched. This can be made a bit more - * correct when the sched_lock is a mutex. - */ - spl = MUTEX_OLDIPL(mtx); - MUTEX_OLDIPL(mtx) = splsched(); - mtx_leave(mtx); - } + /* XXX - We need to make sure that the mutex doesn't + * unblock splsched. This can be made a bit more + * correct when the sched_lock is a mutex. + */ + spl = MUTEX_OLDIPL(mtx); + MUTEX_OLDIPL(mtx) = splsched(); + mtx_leave(mtx); sleep_finish(&sls, 1); error1 = sleep_finish_timeout(&sls); error = sleep_finish_signal(&sls); - if (mtx) { - if ((priority & PNORELOCK) == 0) { - mtx_enter(mtx); - MUTEX_OLDIPL(mtx) = spl; /* put the ipl back */ - } else - splx(spl); - } + if ((priority & PNORELOCK) == 0) { + mtx_enter(mtx); + MUTEX_OLDIPL(mtx) = spl; /* put the ipl back */ + } else + splx(spl); + /* Signal errors are higher priority than timeouts. */ if (error == 0 && error1 != 0) error = error1; |