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>
diff --git a/ChangeLog.d/fix_psa_crypto_leak.txt b/ChangeLog.d/fix_psa_crypto_leak.txt
new file mode 100644
index 0000000..5add73d
--- /dev/null
+++ b/ChangeLog.d/fix_psa_crypto_leak.txt
@@ -0,0 +1,2 @@
+Bugfix
+ * Fix memory leak that occured in error case in psa_generate_derived_key_internal()
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index c00875b..0855b02 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -5147,7 +5147,7 @@
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 = {