From: Kevin Day Date: Tue, 29 Mar 2022 23:23:25 +0000 (-0500) Subject: Security: Controller program is not initializing the alert mutex lock. X-Git-Tag: 0.5.9~52 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=b91dbd89771083655c558e3dc82c793a6d20370f;p=fll Security: Controller program is not initializing the alert mutex lock. This results in undefined behavior and a possible segfault. This appears to be an oversight. Also remove stale commented out code and slightly improve the wording in a comment. --- diff --git a/level_3/controller/c/lock/private-lock.c b/level_3/controller/c/lock/private-lock.c index 110dcc7..3f9489a 100644 --- a/level_3/controller/c/lock/private-lock.c +++ b/level_3/controller/c/lock/private-lock.c @@ -14,9 +14,6 @@ extern "C" { f_status_t status = f_thread_mutex_create(0, &lock->alert); if (F_status_is_error(status)) return status; - //status = f_thread_mutex_create(0, &lock->listen); - //if (F_status_is_error(status)) return status; - status = f_thread_mutex_create(0, &lock->print); if (F_status_is_error(status)) return status; @@ -26,11 +23,11 @@ extern "C" { status = f_thread_lock_create(0, &lock->rule); if (F_status_is_error(status)) return status; - status = f_thread_condition_create(0, &lock->alert_condition); + status = f_thread_lock_create(0, &lock->alert); if (F_status_is_error(status)) return status; - //status = f_thread_condition_create(0, &lock->listen_condition); - //if (F_status_is_error(status)) return status; + status = f_thread_condition_create(0, &lock->alert_condition); + if (F_status_is_error(status)) return status; return F_none; } diff --git a/level_3/controller/c/thread/private-thread_process.c b/level_3/controller/c/thread/private-thread_process.c index 5ce3c88..e57446c 100644 --- a/level_3/controller/c/thread/private-thread_process.c +++ b/level_3/controller/c/thread/private-thread_process.c @@ -50,7 +50,7 @@ extern "C" { return; } - // Use the alert lock to toggle enabled (being used as if it were a write like and signal lock). + // Use the alert lock to toggle enabled (using it as if it is a write like and a signal lock). f_status_t status = f_thread_mutex_lock(&global.thread->lock.alert); if (F_status_is_error(status)) {