Skip to content

Commit ee24a31

Browse files
ycaibbsjaeckel
authored andcommitted
fix missing mutex unlock
Fixes a missing mutex unlock on an out of memory error in ltc_ecc_fp_save_state(). Originates from: OP-TEE/optee_os@4af447d Fixes #571 Comment by sj: This patch version slightly deviates from the original patch to OP-TEE since we don't call `XFREE(NULL)` as there exist implementations of `free()` that don't support it. Signed-off-by: Ryan Cai <[email protected]> Reviewed-by: Jens Wiklander <[email protected]> Modified-by: Steffen Jaeckel <[email protected]>
1 parent 2cb51b6 commit ee24a31

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/math/fp/ltc_ecc_fp_mulmod.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,8 +1429,10 @@ int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen)
14291429
* and the mu INTEGER
14301430
*/
14311431
cache_entry = XCALLOC(FP_ENTRIES*(2*(1U<<FP_LUT)+4)+3, sizeof(ltc_asn1_list));
1432-
if (cache_entry == NULL)
1432+
if (cache_entry == NULL) {
1433+
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
14331434
return CRYPT_MEM;
1435+
}
14341436
j = 1; /* handle the zero'th element later */
14351437

14361438
LTC_SET_ASN1(cache_entry, j++, LTC_ASN1_SHORT_INTEGER, &fp_entries, 1);

0 commit comments

Comments
 (0)