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.
This commit is contained in:
parent
c932615213
commit
7ada587697
@ -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
|
||||
|
@ -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 |
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user