From: fincs Date: Wed, 7 Oct 2015 19:48:26 +0000 (+0200) Subject: Fix potential race condition in LightLock_Unlock() (spotted by mtheall) X-Git-Tag: v1.0.0~81 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=141703b4eee4a7f8eb4b09d366d31af64181a907;p=corbenik%2Fctrulib.git Fix potential race condition in LightLock_Unlock() (spotted by mtheall) --- diff --git a/libctru/source/synchronization.c b/libctru/source/synchronization.c index 146a539..9bc293f 100644 --- a/libctru/source/synchronization.c +++ b/libctru/source/synchronization.c @@ -50,7 +50,7 @@ void LightLock_Unlock(LightLock* lock) // Wake up exactly one thread do val = __ldrex(lock); - while (__strex(lock, val-1)); + while (__strex(lock, val >= 0 ? (val-1) : (val+1))); svcArbitrateAddress(arbiter, (u32)lock, ARBITRATION_SIGNAL, 1, 0); } }