--- /usr/src/sys/kern/kern_lock.c Wed Jan 9 01:02:43 2008 +++ sys/kern/kern_lock.c Fri Jan 11 12:49:01 2008 @@ -545,6 +545,9 @@ { struct thread *td; + /* If the kernel panicked, avoid to panic again on assertions. */ + if (panicstr != NULL) + return; td = curthread; KASSERT(lkp->lk_exclusivecount, ("%s: %p lockmgr must be exclusively locked", __func__, lkp)); @@ -555,7 +558,9 @@ /* * Drop the lock reference and switch the owner. This will result * in an atomic operation like td_lock is only accessed by curthread - * and lk_lockholder only needs one write. + * and lk_lockholder only needs one write. Note also that the lock + * owner can be alredy KERNPROC, so in that case just skip the + * decrement. */ if (lkp->lk_lockholder == td) td->td_locks--;