psa: slot mgmt: Add access counter overflow check
It adds a bit a code for not much but that way we
are such that a count overflow cannot occur.
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c
index 5d20532..943923f 100644
--- a/library/psa_crypto_slot_management.c
+++ b/library/psa_crypto_slot_management.c
@@ -133,8 +133,9 @@
if( status == PSA_SUCCESS )
{
- *p_slot = slot;
- psa_increment_key_slot_access_count( slot );
+ status = psa_increment_key_slot_access_count( slot );
+ if( status == PSA_SUCCESS )
+ *p_slot = slot;
}
return( status );
@@ -208,10 +209,13 @@
if( selected_slot != NULL )
{
+ status = psa_increment_key_slot_access_count( selected_slot );
+ if( status != PSA_SUCCESS )
+ goto error;
+
*volatile_key_id = PSA_KEY_ID_VOLATILE_MIN +
( (psa_key_id_t)( selected_slot - global_data.key_slots ) );
*p_slot = selected_slot;
- psa_increment_key_slot_access_count( selected_slot );
return( PSA_SUCCESS );
}