SPM: Optimize the PSA API error handling process

In SPM implementation, message is a struct inside connection
handle struct and therefore it is unnecessary to check whether
the message pointer is NULL.

This patch:
- Skips checking message pointer after getting it from the
  connection handle.
- Returns an error code instead of calling tfm_core_panic()
  in some error processing.

Change-Id: Id45e63f8bbdd3d21db3ee32b43f4553ab7520a8f
Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
diff --git a/secure_fw/spm/ffm/backend_sfn.c b/secure_fw/spm/ffm/backend_sfn.c
index 6cf39d5..3edde0c 100644
--- a/secure_fw/spm/ffm/backend_sfn.c
+++ b/secure_fw/spm/ffm/backend_sfn.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -42,7 +42,7 @@
     psa_status_t status;
 
     if (!msg || !service || !service->p_ldinf || !service->partition) {
-        tfm_core_panic();
+        return PSA_ERROR_PROGRAMMER_ERROR;
     }
 
     msg->sfn_magic = TFM_MSG_MAGIC_SFN;
@@ -56,7 +56,7 @@
             status = ((sfn_init_fn_t)p_target->p_ldinf->entry)();
             /* Negative value indicates errors. */
             if (status < PSA_SUCCESS) {
-                tfm_core_panic();
+                return PSA_ERROR_PROGRAMMER_ERROR;
             }
         }
         p_target->state = SFN_PARTITION_STATE_INITED;