summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-10-20 01:22:42 +0000
committerjhb <jhb@FreeBSD.org>2001-10-20 01:22:42 +0000
commit5eebcc2012bc54d4b3406751b23d1a6129d07123 (patch)
tree07ffe6f4c106e0b31731ebc822d103967082d5bd /sys/kern/kern_mutex.c
parentce20b502fbae59491abc3395683d5ce71eb060b6 (diff)
downloadFreeBSD-src-5eebcc2012bc54d4b3406751b23d1a6129d07123.zip
FreeBSD-src-5eebcc2012bc54d4b3406751b23d1a6129d07123.tar.gz
The mtx_init() and sx_init() functions bzero'd locks before handing them
off to witness_init() making the check for double intializating a lock by testing the LO_INITIALIZED flag moot. Workaround this by checking the LO_INITIALIZED flag ourself before we bzero the lock structure.
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 8dc6a03..ba6efe5 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -670,8 +670,10 @@ mtx_init(struct mtx *m, const char *description, int opts)
mtx_validate(m);
#endif
- bzero(m, sizeof(*m));
lock = &m->mtx_object;
+ KASSERT((lock->lo_flags & LO_INITIALIZED) == 0,
+ ("mutex %s %p already initialized", description, m));
+ bzero(m, sizeof(*m));
if (opts & MTX_SPIN)
lock->lo_class = &lock_class_mtx_spin;
else
OpenPOWER on IntegriCloud