From 079e7c569230768e00622d621453099c628d79c3 Mon Sep 17 00:00:00 2001 From: Jeremiah Mackey Date: Thu, 26 Mar 2026 16:38:28 +0000 Subject: [PATCH] fix SE050 mutex leaks on early returns --- wolfcrypt/src/port/nxp/se050_port.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wolfcrypt/src/port/nxp/se050_port.c b/wolfcrypt/src/port/nxp/se050_port.c index da652eda26..a4524aacc1 100644 --- a/wolfcrypt/src/port/nxp/se050_port.c +++ b/wolfcrypt/src/port/nxp/se050_port.c @@ -572,6 +572,7 @@ int wc_se050_insert_binary_object(word32 keyId, const byte* object, /* Avoid key ID conflicts with temporary key storage */ if (keyId >= SE050_KEYID_START) { + wolfSSL_CryptHwMutexUnLock(); return BAD_FUNC_ARG; } @@ -636,10 +637,12 @@ int wc_se050_get_binary_object(word32 keyId, byte* out, word32* outSz) else { if (out == NULL) { *outSz = ret; + wolfSSL_CryptHwMutexUnLock(); return WC_NO_ERR_TRACE(LENGTH_ONLY_E); } if ((word32)ret > *outSz) { WOLFSSL_MSG("Output buffer not large enough for object"); + wolfSSL_CryptHwMutexUnLock(); return BAD_LENGTH_E; } ret = 0; @@ -931,6 +934,7 @@ static int se050_rsa_insert_key(word32 keyId, const byte* rsaDer, /* Avoid key ID conflicts with temporary key storage */ if (keyId >= SE050_KEYID_START) { + wolfSSL_CryptHwMutexUnLock(); return BAD_FUNC_ARG; }