From 362c307d8477fbf2c9d858b3a3390a86d1a97673 Mon Sep 17 00:00:00 2001 From: itayzafrir Date: Thu, 28 Feb 2019 11:02:08 +0200 Subject: [PATCH] Free dynamic memory in crypto proxy --- .../COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c b/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c index a58dc94ec6..79c1cc97d5 100644 --- a/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c +++ b/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c @@ -412,12 +412,13 @@ psa_status_t psa_aead_encrypt(psa_key_handle_t key_handle, handle = psa_connect(PSA_AEAD_ID, MINOR_VER); if (handle <= 0) { - return (PSA_ERROR_COMMUNICATION_FAILURE); + status = PSA_ERROR_COMMUNICATION_FAILURE; + } else { + status = psa_call(handle, in_vec, 2, out_vec, 2); + psa_close(handle); } - status = psa_call(handle, in_vec, 2, out_vec, 2); - psa_close(handle); - + free(buffer); return (status); } @@ -480,12 +481,13 @@ psa_status_t psa_aead_decrypt(psa_key_handle_t key_handle, handle = psa_connect(PSA_AEAD_ID, MINOR_VER); if (handle <= 0) { - return (PSA_ERROR_COMMUNICATION_FAILURE); + status = PSA_ERROR_COMMUNICATION_FAILURE; + } else { + status = psa_call(handle, in_vec, 2, out_vec, 2); + psa_close(handle); } - status = psa_call(handle, in_vec, 2, out_vec, 2); - psa_close(handle); - + free(buffer); return (status); } @@ -620,12 +622,13 @@ static psa_status_t psa_asymmetric_operation(psa_sec_function_t func, handle = psa_connect(PSA_ASYMMETRIC_ID, MINOR_VER); if (handle <= 0) { - return (PSA_ERROR_COMMUNICATION_FAILURE); + status = PSA_ERROR_COMMUNICATION_FAILURE; + } else { + status = psa_call(handle, in_vec, 2, out_vec, 2); + psa_close(handle); } - status = psa_call(handle, in_vec, 2, out_vec, 2); - psa_close(handle); - + free(buffer); return (status); }