From 8eaaf58a5f62fc8fcce50c619d34b58e6957e67c Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Thu, 9 Feb 2017 13:32:19 +0000 Subject: [PATCH] rwlock: fix r313454 The runlock slow path would update wrong variable before restarting the loop, in effect corrupting the state. Reported by: pho --- sys/kern/kern_rwlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index be1c42e8ee0a..9464588b9eda 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -755,7 +755,7 @@ __rw_runlock_hard(volatile uintptr_t *c, struct thread *td, uintptr_t v, if (!atomic_cmpset_rel_ptr(&rw->rw_lock, RW_READERS_LOCK(1) | v, x)) { turnstile_chain_unlock(&rw->lock_object); - x = RW_READ_VALUE(rw); + v = RW_READ_VALUE(rw); continue; } if (LOCK_LOG_TEST(&rw->lock_object, 0))