Fix return code error when locking mutex

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c
index 53ebf31..b0744bd 100644
--- a/library/psa_crypto_slot_management.c
+++ b/library/psa_crypto_slot_management.c
@@ -349,6 +349,9 @@
     }
 
 #if defined(MBEDTLS_THREADING_C)
+    /* We need to set status as success, otherwise CORRUPTION_DETECTED
+     * would be returned if the lock fails. */
+    status = PSA_SUCCESS;
     /* If the key is persistent and not loaded, we cannot unlock the mutex
      * between checking if the key is loaded and setting the slot as FULL,
      * as otherwise another thread may load and then destroy the key
@@ -462,6 +465,9 @@
 {
     psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
 #if defined(MBEDTLS_THREADING_C)
+    /* We need to set status as success, otherwise CORRUPTION_DETECTED
+     * would be returned if the lock fails. */
+    status = PSA_SUCCESS;
     PSA_THREADING_CHK_RET(mbedtls_mutex_lock(
                               &mbedtls_threading_key_slot_mutex));
 #endif