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.h b/library/psa_crypto_slot_management.h
index 75ce0ac..db5acba 100644
--- a/library/psa_crypto_slot_management.h
+++ b/library/psa_crypto_slot_management.h
@@ -137,10 +137,21 @@
  * This function increments the slot access counter by one.
  *
  * \param[in] slot  The key slot.
+ *
+ * \retval #PSA_SUCCESS
+               The access count was incremented.
+ * \retval #PSA_ERROR_CORRUPTION_DETECTED
+ *             The access count already reached its maximum value and was not
+ *             increased.
  */
-static inline void psa_increment_key_slot_access_count( psa_key_slot_t *slot )
+static inline psa_status_t psa_increment_key_slot_access_count( psa_key_slot_t *slot )
 {
+    if( slot->access_count >= SIZE_MAX )
+        return( PSA_ERROR_CORRUPTION_DETECTED );
+
     slot->access_count++;
+
+    return( PSA_SUCCESS );
 }
 
 /** Decrement slot access counter.