Fix error handling in psa_driver_wrapper_xxx_hash_get_num_ops

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 1faf1dd..8e339ea 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -3470,7 +3470,9 @@
                                                    signature_length);
 
     /* Update ops count with work done. */
-    operation->num_ops = psa_driver_wrapper_sign_hash_get_num_ops(operation);
+    if (status == PSA_SUCCESS) {
+        status = psa_driver_wrapper_sign_hash_get_num_ops(operation, &operation->num_ops);
+    }
 
 exit:
 
@@ -3601,8 +3603,9 @@
     status = psa_driver_wrapper_verify_hash_complete(operation);
 
     /* Update ops count with work done. */
-    operation->num_ops = psa_driver_wrapper_verify_hash_get_num_ops(
-        operation);
+    if (status == PSA_SUCCESS) {
+        status = psa_driver_wrapper_verify_hash_get_num_ops(operation, &operation->num_ops);
+    }
 
 exit: