Skip to content

Commit 362c307

Browse files
author
itayzafrir
committed
Free dynamic memory in crypto proxy
1 parent 0e7f112 commit 362c307

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,13 @@ psa_status_t psa_aead_encrypt(psa_key_handle_t key_handle,
412412

413413
handle = psa_connect(PSA_AEAD_ID, MINOR_VER);
414414
if (handle <= 0) {
415-
return (PSA_ERROR_COMMUNICATION_FAILURE);
415+
status = PSA_ERROR_COMMUNICATION_FAILURE;
416+
} else {
417+
status = psa_call(handle, in_vec, 2, out_vec, 2);
418+
psa_close(handle);
416419
}
417420

418-
status = psa_call(handle, in_vec, 2, out_vec, 2);
419-
psa_close(handle);
420-
421+
free(buffer);
421422
return (status);
422423
}
423424

@@ -480,12 +481,13 @@ psa_status_t psa_aead_decrypt(psa_key_handle_t key_handle,
480481

481482
handle = psa_connect(PSA_AEAD_ID, MINOR_VER);
482483
if (handle <= 0) {
483-
return (PSA_ERROR_COMMUNICATION_FAILURE);
484+
status = PSA_ERROR_COMMUNICATION_FAILURE;
485+
} else {
486+
status = psa_call(handle, in_vec, 2, out_vec, 2);
487+
psa_close(handle);
484488
}
485489

486-
status = psa_call(handle, in_vec, 2, out_vec, 2);
487-
psa_close(handle);
488-
490+
free(buffer);
489491
return (status);
490492
}
491493

@@ -620,12 +622,13 @@ static psa_status_t psa_asymmetric_operation(psa_sec_function_t func,
620622

621623
handle = psa_connect(PSA_ASYMMETRIC_ID, MINOR_VER);
622624
if (handle <= 0) {
623-
return (PSA_ERROR_COMMUNICATION_FAILURE);
625+
status = PSA_ERROR_COMMUNICATION_FAILURE;
626+
} else {
627+
status = psa_call(handle, in_vec, 2, out_vec, 2);
628+
psa_close(handle);
624629
}
625630

626-
status = psa_call(handle, in_vec, 2, out_vec, 2);
627-
psa_close(handle);
628-
631+
free(buffer);
629632
return (status);
630633
}
631634

0 commit comments

Comments
 (0)