lockmgr() function will return successfully when trying to work under

panic but it won't actually lock anything.
This can lead some paths to reach lockmgr_disown() with inconsistent
lock which will let trigger the relative assertions.

Fix those in order to recognize panic situation and to not trigger.

Reported by: pho
Submitted by: kib
This commit is contained in:
Attilio Rao 2008-01-11 16:38:12 +00:00
parent 548868b38d
commit d1127e669c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=175229

View file

@ -546,16 +546,19 @@ lockmgr_disown(struct lock *lkp)
struct thread *td;
td = curthread;
KASSERT(lkp->lk_exclusivecount,
KASSERT(panicstr != NULL || lkp->lk_exclusivecount,
("%s: %p lockmgr must be exclusively locked", __func__, lkp));
KASSERT(lkp->lk_lockholder == td || lkp->lk_lockholder == LK_KERNPROC,
KASSERT(panicstr != NULL || lkp->lk_lockholder == td ||
lkp->lk_lockholder == LK_KERNPROC,
("%s: %p lockmgr must be locked by curthread (%p)", __func__, lkp,
td));
/*
* 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--;