core: spmc: move FIP SP deinit call

Move the FIP SP deinit call to before starting the SPs. This change does
not affect functionality, it's just to make the SP packages' lifetime
clearer in the code.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
diff --git a/core/arch/arm/kernel/secure_partition.c b/core/arch/arm/kernel/secure_partition.c
index 235a100..ac2cd23 100644
--- a/core/arch/arm/kernel/secure_partition.c
+++ b/core/arch/arm/kernel/secure_partition.c
@@ -1590,6 +1590,12 @@
 		}
 	}
 
+	/*
+	 * At this point all FIP SPs are loaded by ldelf or by the raw binary SP
+	 * loader, so the original images (loaded by BL2) are not needed anymore
+	 */
+	fip_sp_deinit_all();
+
 	/* Continue the initialization and run the SP */
 	TAILQ_FOREACH(s, &open_sp_sessions, link) {
 		res = sp_first_run(s);
@@ -1601,12 +1607,6 @@
 		}
 	}
 
-	/*
-	 * At this point all FIP SPs are loaded by ldelf or by the raw binary SP
-	 * loader, so the original images (loaded by BL2) are not needed anymore
-	 */
-	fip_sp_deinit_all();
-
 	return TEE_SUCCESS;
 }