Skip to content

Commit b844395

Browse files
author
Cruz Monrreal
authored
Merge pull request #9883 from itayzafrir/crypto-service-proxy-mem-fix
Free dynamic memory in Crypto Service proxy (PSA targets)
2 parents b5878b1 + 362c307 commit b844395

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 numberOriginal file lineDiff line numberDiff line change
@@ -412,12 +412,13 @@ psa_status_t psa_aead_encrypt(psa_key_handle_t key_handle,
412

412

413
handle = psa_connect(PSA_AEAD_ID, MINOR_VER);
413
handle = psa_connect(PSA_AEAD_ID, MINOR_VER);
414
if (handle <= 0) {
414
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);
416
}
419
}
417

420

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

424

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

481

481
handle = psa_connect(PSA_AEAD_ID, MINOR_VER);
482
handle = psa_connect(PSA_AEAD_ID, MINOR_VER);
482
if (handle <= 0) {
483
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);
484
}
488
}
485

489

486-
status = psa_call(handle, in_vec, 2, out_vec, 2);
490+
free(buffer);
487-
psa_close(handle);
488-
489
return (status);
491
return (status);
490
}
492
}
491

493

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

622

621
handle = psa_connect(PSA_ASYMMETRIC_ID, MINOR_VER);
623
handle = psa_connect(PSA_ASYMMETRIC_ID, MINOR_VER);
622
if (handle <= 0) {
624
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);
624
}
629
}
625

630

626-
status = psa_call(handle, in_vec, 2, out_vec, 2);
631+
free(buffer);
627-
psa_close(handle);
628-
629
return (status);
632
return (status);
630
}
633
}
631

634

0 commit comments

Comments
 (0)