Ensure that key gets unlocked in case of error

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 9c7a380..adf3b2b 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -3280,14 +3280,12 @@
 
     operation->key_type = psa_get_key_type( &attributes );
 
+exit:
+
     unlock_status = psa_unlock_key_slot( slot );
 
     if( unlock_status != PSA_SUCCESS )
-    {
         status = unlock_status;
-    }
-
-exit:
 
     if( status == PSA_SUCCESS )
         operation->alg = psa_aead_get_base_algorithm( alg );
@@ -3339,15 +3337,18 @@
                                                     &attributes, slot->key.data,
                                                     slot->key.bytes, alg );
 
+    if( status != PSA_SUCCESS )
+        goto exit;
+
     operation->key_type = psa_get_key_type( &attributes );
 
+exit:
+
     unlock_status = psa_unlock_key_slot( slot );
 
     if( unlock_status != PSA_SUCCESS )
         status = unlock_status;
 
-exit:
-
     if( status == PSA_SUCCESS )
         operation->alg = psa_aead_get_base_algorithm( alg );
     else