Skip to content

Commit f39190b

Browse files
frkvrlubos
authored andcommitted
crypto: mutex: Fix boolean for dynamically allocated mutexes
-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]> (cherry picked from commit 50340a3)
1 parent f00620e commit f39190b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

subsys/nrf_security/src/utils/nrf_security_mutexes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
void nrf_security_mutex_init(mbedtls_threading_mutex_t * mutex)
2121
{
22-
if((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
22+
if ((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) == 0) {
2323
k_mutex_init(&mutex->mutex);
2424
}
2525

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

3434
int nrf_security_mutex_lock(mbedtls_threading_mutex_t * mutex)
3535
{
36-
if((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
36+
if ((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
3737
return k_mutex_lock(&mutex->mutex, K_FOREVER);
3838
} else {
3939
return -EINVAL;
@@ -42,7 +42,7 @@ int nrf_security_mutex_lock(mbedtls_threading_mutex_t * mutex)
4242

4343
int nrf_security_mutex_unlock(mbedtls_threading_mutex_t * mutex)
4444
{
45-
if((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
45+
if ((mutex->flags & NRF_SECURITY_MUTEX_FLAGS_INITIALIZED) != 0) {
4646
return k_mutex_unlock(&mutex->mutex);
4747
} else {
4848
return -EINVAL;

0 commit comments

Comments
 (0)