From 5dcdaf9e698f0397e4ddf701ed74032455fd6104 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Mon, 22 Jan 2018 16:08:23 +0100 Subject: [PATCH] core: prevent crash in tee_mmu_final() on TA loading error If the creation of the TA execution context fails before the mapping directives are initialized, tee_mmu_final() will be called with the TA context field mmu being NULL. This change allows tee_mmu_final() to be called with uninitialized mapping resources without crashing the core. Signed-off-by: Etienne Carriere --- core/arch/arm/mm/tee_mmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/arch/arm/mm/tee_mmu.c b/core/arch/arm/mm/tee_mmu.c index af1c8670a01..dc666c67a4b 100644 --- a/core/arch/arm/mm/tee_mmu.c +++ b/core/arch/arm/mm/tee_mmu.c @@ -676,6 +676,9 @@ void tee_mmu_rem_rwmem(struct user_ta_ctx *utc, struct mobj *mobj, vaddr_t va) */ void tee_mmu_final(struct user_ta_ctx *utc) { + if (!utc->mmu) + return; + /* clear MMU entries to avoid clash when asid is reused */ tlbi_asid(utc->mmu->asid);