From 84b736b2687b4fc63cd29f2035d60ee749b215be Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 25 Feb 2015 16:17:16 +0000 Subject: [PATCH] When failing to claim ownership of a umtx_pi, restore the umutex owner to its previous, unowned state. This avoids compounding an existing problem of inconsistent ownership. Submitted by: Eric van Gyzen Obtained from: Dell Inc. PR: 198914 MFC after: 1 week --- sys/kern/kern_umtx.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 75aa1d8d4a02..721f4f0efa30 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -1741,6 +1741,17 @@ do_lock_pi(struct thread *td, struct umutex *m, uint32_t flags, error = umtx_pi_claim(pi, td); umtxq_unbusy(&uq->uq_key); umtxq_unlock(&uq->uq_key); + if (error != 0) { + /* + * Since we're going to return an + * error, restore the m_owner to its + * previous, unowned state to avoid + * compounding the problem. + */ + (void)casuword32(&m->m_owner, + id | UMUTEX_CONTESTED, + UMUTEX_CONTESTED); + } break; }