Skip to content

Commit 079e7c5

Browse files
committed
fix SE050 mutex leaks on early returns
1 parent 5ff7fde commit 079e7c5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

wolfcrypt/src/port/nxp/se050_port.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ int wc_se050_insert_binary_object(word32 keyId, const byte* object,
572572

573573
/* Avoid key ID conflicts with temporary key storage */
574574
if (keyId >= SE050_KEYID_START) {
575+
wolfSSL_CryptHwMutexUnLock();
575576
return BAD_FUNC_ARG;
576577
}
577578

@@ -636,10 +637,12 @@ int wc_se050_get_binary_object(word32 keyId, byte* out, word32* outSz)
636637
else {
637638
if (out == NULL) {
638639
*outSz = ret;
640+
wolfSSL_CryptHwMutexUnLock();
639641
return WC_NO_ERR_TRACE(LENGTH_ONLY_E);
640642
}
641643
if ((word32)ret > *outSz) {
642644
WOLFSSL_MSG("Output buffer not large enough for object");
645+
wolfSSL_CryptHwMutexUnLock();
643646
return BAD_LENGTH_E;
644647
}
645648
ret = 0;
@@ -931,6 +934,7 @@ static int se050_rsa_insert_key(word32 keyId, const byte* rsaDer,
931934

932935
/* Avoid key ID conflicts with temporary key storage */
933936
if (keyId >= SE050_KEYID_START) {
937+
wolfSSL_CryptHwMutexUnLock();
934938
return BAD_FUNC_ARG;
935939
}
936940

0 commit comments

Comments
 (0)