Skip to content

Commit

Permalink
crypto: mutex: Fix boolean for dynamically allocated mutexes
Browse files Browse the repository at this point in the history
-Boolean error in mutex initialization prevented mutexes from being
 initialized. This commit fixes this.
-Fixing some spacing issues (conformance)

ref: NCSDK-29941

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
  • Loading branch information
frkv authored and rlubos committed Oct 25, 2024
1 parent b24793a commit 50340a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions subsys/nrf_security/src/utils/nrf_security_mutexes.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

void nrf_security_mutex_init(mbedtls_threading_mutex_t * mutex)
{
if((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
if ((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) == 0) {
k_mutex_init(&mutex->mutex);
}

Expand All @@ -33,7 +33,7 @@ void nrf_security_mutex_free(mbedtls_threading_mutex_t * mutex)

int nrf_security_mutex_lock(mbedtls_threading_mutex_t * mutex)
{
if((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
if ((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
return k_mutex_lock(&mutex->mutex, K_FOREVER);
} else {
return -EINVAL;
Expand All @@ -42,7 +42,7 @@ int nrf_security_mutex_lock(mbedtls_threading_mutex_t * mutex)

int nrf_security_mutex_unlock(mbedtls_threading_mutex_t * mutex)
{
if((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
if ((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
return k_mutex_unlock(&mutex->mutex);
} else {
return -EINVAL;
Expand Down

0 comments on commit 50340a3

Please sign in to comment.