summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2011-04-03 22:26:24 +0000
committermiod <miod@openbsd.org>2011-04-03 22:26:24 +0000
commit5918836abfdacc3093dfce920ca68e3d12a366e9 (patch)
treeb1f8d072d4316c4a02e3ff93f9a4c6f6eb107f04 /sys
parentHelper functions for suspend. (diff)
downloadwireguard-openbsd-5918836abfdacc3093dfce920ca68e3d12a366e9.tar.xz
wireguard-openbsd-5918836abfdacc3093dfce920ca68e3d12a366e9.zip
In mtx_leave(), make sure resetting mtx_lock is the last operation on the
struct mutex. Modelled after hppa.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/octeon/octeon/mutex.c9
-rw-r--r--sys/arch/sgi/sgi/mutex.c9
2 files changed, 12 insertions, 6 deletions
diff --git a/sys/arch/octeon/octeon/mutex.c b/sys/arch/octeon/octeon/mutex.c
index 1d6ae9a7a6a..52c35e003b4 100644
--- a/sys/arch/octeon/octeon/mutex.c
+++ b/sys/arch/octeon/octeon/mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.c,v 1.3 2011/04/03 18:46:40 miod Exp $ */
+/* $OpenBSD: mutex.c,v 1.4 2011/04/03 22:26:24 miod Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -106,11 +106,14 @@ mtx_enter_try(struct mutex *mtx)
void
mtx_leave(struct mutex *mtx)
{
+ int s;
+
MUTEX_ASSERT_LOCKED(mtx);
#ifdef DIAGNOSTIC
curcpu()->ci_mutex_level--;
#endif
- mtx->mtx_lock = 0;
- splx(mtx->mtx_oldipl);
+ s = mtx->mtx_oldipl;
mtx->mtx_owner = NULL;
+ mtx->mtx_lock = 0;
+ splx(s);
}
diff --git a/sys/arch/sgi/sgi/mutex.c b/sys/arch/sgi/sgi/mutex.c
index 1f699521bb8..57ca2e62ff3 100644
--- a/sys/arch/sgi/sgi/mutex.c
+++ b/sys/arch/sgi/sgi/mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.c,v 1.10 2011/04/03 18:46:40 miod Exp $ */
+/* $OpenBSD: mutex.c,v 1.11 2011/04/03 22:26:24 miod Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -104,11 +104,14 @@ mtx_enter_try(struct mutex *mtx)
void
mtx_leave(struct mutex *mtx)
{
+ int s;
+
MUTEX_ASSERT_LOCKED(mtx);
#ifdef DIAGNOSTIC
curcpu()->ci_mutex_level--;
#endif
- mtx->mtx_lock = 0;
- splx(mtx->mtx_oldipl);
+ s = mtx->mtx_oldipl;
mtx->mtx_owner = NULL;
+ mtx->mtx_lock = 0;
+ splx(s);
}