diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 8340b214b23e..be3ca31df356 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -1849,10 +1849,10 @@ enroll(const char *description, struct lock_class *lock_class) return (w); found: w->w_refcount++; - mtx_unlock_spin(&w_mtx); if (w->w_refcount == 1) w->w_class = lock_class; - else if (lock_class != w->w_class) + mtx_unlock_spin(&w_mtx); + if (lock_class != w->w_class) kassert_panic( "lock (%s) %s does not match earlier (%s) lock", description, lock_class->lc_name,