From b35ad5b523ec8fcb2f247c1c6700af2a244115b7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 14 Sep 2019 19:35:07 +0200 Subject: [PATCH] Kernel: Fix bad assertion in Lock::unlock_if_locked() We shouldn't assert if you call this on a Lock held by another Thread in the same Process. Instead, we should just not unlock. --- Kernel/Lock.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Kernel/Lock.cpp b/Kernel/Lock.cpp index c19f479f640..73446853072 100644 --- a/Kernel/Lock.cpp +++ b/Kernel/Lock.cpp @@ -49,11 +49,13 @@ bool Lock::unlock_if_locked() for (;;) { if (CAS(&m_lock, 1, 0) == 0) { if (m_level == 0) { - memory_barrier(); m_lock = 0; return false; } - ASSERT(m_holder == current); + if (m_holder != current) { + m_lock = 0; + return false; + } ASSERT(m_level); --m_level; if (m_level) {