Core: Check next for NULL before scheduling

If all the threads except for the current one are blocked, the function
tfm_thrd_next_thread(...) returns null. This can happen if a secure
service is waiting on an interrupt signal.

To prevent assertation failure in tfm_thrd_context_switch(...), the
'pth_next' pointer have to be checked for NULL, and only do context
switch if the pointer is not NULL.

Change-Id: Ic52752df5b795c3ad7f0a6768f2d64ca7fc3ba26
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/secure_fw/core/ipc/tfm_spm.c b/secure_fw/core/ipc/tfm_spm.c
index 0eee6f4..c10bcc8 100644
--- a/secure_fw/core/ipc/tfm_spm.c
+++ b/secure_fw/core/ipc/tfm_spm.c
@@ -586,7 +586,7 @@
     struct tfm_thrd_ctx *pth_next = tfm_thrd_next_thread();
     struct tfm_thrd_ctx *pth_curr = tfm_thrd_curr_thread();
 
-    if (pth_curr != pth_next) {
+    if (pth_next != NULL && pth_curr != pth_next) {
 #if TFM_LVL == 2
         p_next_partition = TFM_GET_CONTAINER_PTR(pth_next,
                                                  struct spm_partition_desc_t,