Furi: Fix Semaphore atomicity

if thread A waiting for acquire(), thread B calls release()
halfway through release() code, A would
wake up and continue, before B finishes release()
this could cause use-after-free if A free()s semaphore after acquire
This commit is contained in:
Willy-JL
2024-11-09 04:42:34 +00:00
parent a26631f11b
commit f30f0c1938
+4
View File
@@ -104,6 +104,8 @@ FuriStatus furi_semaphore_release(FuriSemaphore* instance) {
stat = FuriStatusOk;
FURI_CRITICAL_ENTER();
if(FURI_IS_IRQ_MODE()) {
yield = pdFALSE;
@@ -123,6 +125,8 @@ FuriStatus furi_semaphore_release(FuriSemaphore* instance) {
furi_event_loop_link_notify(&instance->event_loop_link, FuriEventLoopEventIn);
}
FURI_CRITICAL_EXIT();
return stat;
}