summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2018-04-25 10:30:41 +0000
committermpi <mpi@openbsd.org>2018-04-25 10:30:41 +0000
commitfdf140bed7e7d0aa2f7f51b01d9a894d4c9bcc46 (patch)
tree5db3a0a7ae7e77f5d84eb41fba47fe05282df563
parentIntroduce fd_iterfile() a new helper function to iterate over `filehead'. (diff)
downloadwireguard-openbsd-fdf140bed7e7d0aa2f7f51b01d9a894d4c9bcc46.tar.xz
wireguard-openbsd-fdf140bed7e7d0aa2f7f51b01d9a894d4c9bcc46.zip
Teach mtx_enter_try(9) to avoid deadlocks after a panic.
ok deraadt@
-rw-r--r--sys/kern/kern_lock.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index 01e0a567b82..53a6603ff7a 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_lock.c,v 1.61 2018/03/27 08:32:29 mpi Exp $ */
+/* $OpenBSD: kern_lock.c,v 1.62 2018/04/25 10:30:41 mpi Exp $ */
/*
* Copyright (c) 2017 Visa Hankala
@@ -262,10 +262,6 @@ __mtx_enter(struct mutex *mtx)
int nticks = __mp_lock_spinout;
#endif
- /* Avoid deadlocks after panic or in DDB */
- if (panicstr || db_active)
- return;
-
while (__mtx_enter_try(mtx) == 0) {
CPU_BUSY_CYCLE();
@@ -285,6 +281,10 @@ __mtx_enter_try(struct mutex *mtx)
struct cpu_info *owner, *ci = curcpu();
int s;
+ /* Avoid deadlocks after panic or in DDB */
+ if (panicstr || db_active)
+ return (1);
+
if (mtx->mtx_wantipl != IPL_NONE)
s = splraise(mtx->mtx_wantipl);