Crypto: crypto_init: Fix missing unmapping of input vectors

tfm_crypto_call_srv performs the initialization and mapping of mm-iovecs
and after the required operation is completed, the outvecs are unmapped.

The invec are not unmapped though, resulting in a situation where
subsequent PSA calls would fail.

Note that currently this is not immediately visible due to the fact that
PSA crypto services are accessed via a static handle, so each call takes
a new connection with a clean mm-iovec status.
It would take a stateful Crypto service to actually fall into the issue
noticed above.

Signed-off-by: Nicola Mazzucato <nicola.mazzucato@arm.com>
Reported-by: Brian Quach <brian@ti.com>
Change-Id: Idb4dc40ff439e177c64ddad2421f8febf6007dcb
diff --git a/secure_fw/partitions/crypto/crypto_init.c b/secure_fw/partitions/crypto/crypto_init.c
index e3a604e..031e3ba 100644
--- a/secure_fw/partitions/crypto/crypto_init.c
+++ b/secure_fw/partitions/crypto/crypto_init.c
@@ -302,6 +302,16 @@
             psa_unmap_outvec(msg->handle, i, out_vec[i].len);
         }
     }
+
+    /*
+     * Unmap from the second element because the first element is read when
+     * parsing the message, hence it is never mapped.
+     */
+    for (i = 1; i < in_len; i++) {
+        if (in_vec[i].base != NULL) {
+            psa_unmap_invec(msg->handle, i);
+        }
+    }
 #else
     /* Write into the IPC framework outputs from the scratch */
     for (i = 0; i < out_len; i++) {