fix(async_context_threadsafe_background_execute_sync): prevent use-after-return by removing worker before semaphore release (#2494)

Ensures the async worker is unregistered from the context before releasing the
blocking thread. This prevents the `sync_func_call_t` stack object from being
accessed after it goes out of scope, avoiding a use-after-return condition
in multicore `async_context_execute_sync()` scenarios.

Fixes raspberrypi/pico-sdk#2433

Signed-off-by: Goran Mišković <schkovich@users.noreply.github.com>
This commit is contained in:
Goran Miskovic 2025-06-03 18:06:35 +02:00 committed by GitHub
parent 1ae2f0e32c
commit a9146b65ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,8 +98,8 @@ typedef struct sync_func_call{
static void handle_sync_func_call(async_context_t *context, async_when_pending_worker_t *worker) {
sync_func_call_t *call = (sync_func_call_t *)worker;
call->rc = call->func(call->param);
sem_release(&call->sem);
async_context_remove_when_pending_worker(context, worker);
sem_release(&call->sem);
}
#endif