summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_lock.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2008-01-11 16:38:12 +0000
committerattilio <attilio@FreeBSD.org>2008-01-11 16:38:12 +0000
commit8032f44d5fb5867dbfe64693babecc4474b79de8 (patch)
treec79988179a5659e9ffbfc0cfc517d61276d672a4 /sys/kern/kern_lock.c
parent77a62a7576565a6bb2c926f2ac28debda7eacd6c (diff)
downloadFreeBSD-src-8032f44d5fb5867dbfe64693babecc4474b79de8.zip
FreeBSD-src-8032f44d5fb5867dbfe64693babecc4474b79de8.tar.gz
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
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r--sys/kern/kern_lock.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index f623bdc..5ce5ffd 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -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--;
OpenPOWER on IntegriCloud