Fix memory leak in error case in psa_crypto

In psa_generate_derived_key_internal() an error case was returning
directly rather than jumping to the exit label, which meant that an
allocated buffer would not be free'd.

Found via coverity.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2021-02-09 18:58:20 +00:00
parent a0b4decff0
commit da3e7db495
2 changed files with 3 additions and 1 deletions

View file

@ -0,0 +1,2 @@
Bugfix
* Fix memory leak that occured in error case in psa_generate_derived_key_internal()

View file

@ -5147,7 +5147,7 @@ static psa_status_t psa_generate_derived_key_internal(
status = psa_allocate_buffer_to_slot( slot, bytes );
if( status != PSA_SUCCESS )
return( status );
goto exit;
slot->attr.bits = (psa_key_bits_t) bits;
psa_key_attributes_t attributes = {