summaryrefslogtreecommitdiffstats
path: root/sys/kern
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
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')
-rw-r--r--sys/kern/kern_mutex.c4
-rw-r--r--sys/kern/kern_sx.c4
-rw-r--r--sys/kern/subr_turnstile.c4
3 files changed, 9 insertions, 3 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
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index df18c1e..5323ea0 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -53,8 +53,10 @@ sx_init(struct sx *sx, const char *description)
{
struct lock_object *lock;
- bzero(sx, sizeof(*sx));
lock = &sx->sx_object;
+ KASSERT((lock->lo_flags & LO_INITIALIZED) == 0,
+ ("sx lock %s %p already initialized", description, sx));
+ bzero(sx, sizeof(*sx));
lock->lo_class = &lock_class_sx;
lock->lo_name = description;
lock->lo_flags = LO_WITNESS | LO_RECURSABLE | LO_SLEEPABLE |
diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c
index 8dc6a03..ba6efe5 100644
--- a/sys/kern/subr_turnstile.c
+++ b/sys/kern/subr_turnstile.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