Skip to content

Commit 6311fde

Browse files
committed
[nrf noup] mbedtls: Fix memory leak
nrf-squash![nrf noup] mbedtls: Fix MbedTLS EC parameter A The MPI bignum's were not freed after use. Fixes SHEL-2851. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 3ee1610 commit 6311fde

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/crypto/crypto_mbedtls-ec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ const struct crypto_bignum *crypto_ec_get_a(struct crypto_ec *e)
5858
/* A = -3 mod P*/
5959
MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(&e->A, &minus_three, &one, &e->group.P, NULL));
6060
cleanup:
61+
mbedtls_mpi_free(&minus_three);
62+
mbedtls_mpi_free(&one);
6163
return (const struct crypto_bignum *)&e->A;
6264
}
6365

@@ -109,6 +111,7 @@ void crypto_ec_deinit(struct crypto_ec *e)
109111
return;
110112
}
111113

114+
mbedtls_mpi_free(&e->A);
112115
mbedtls_ecp_group_free(&e->group);
113116
os_free(e);
114117
}

0 commit comments

Comments
 (0)