From a969e99e9f5ac5fe1c7820604748eca2ad88d16f Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Thu, 16 Jan 2025 11:16:03 +0100 Subject: [PATCH] core: mm: zero initialize tee_mm pool structures Zero initialize tee_mm_pool_t instance when such pool is initialized. This change fixes an issue where phys_mem pool max_allocated field may contain a fuzzy value because it was not zero-initialized when allocated by the commit referred below. Fixes: c596d8359eb3 ("core: add phys_mem allocation functions") Signed-off-by: Etienne Carriere Reviewed-by: Jens Wiklander Reviewed-by: Jerome Forissier --- core/mm/tee_mm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/mm/tee_mm.c b/core/mm/tee_mm.c index 5f6bf35139c..0596b724b25 100644 --- a/core/mm/tee_mm.c +++ b/core/mm/tee_mm.c @@ -51,12 +51,14 @@ bool tee_mm_init(tee_mm_pool_t *pool, paddr_t lo, paddr_size_t size, assert(((uint64_t)size >> shift) < (uint64_t)UINT32_MAX); - pool->lo = lo; - pool->size = size; - pool->shift = shift; - pool->flags = flags; - pool->entry = pcalloc(pool, 1, sizeof(tee_mm_entry_t)); + *pool = (tee_mm_pool_t){ + .lo = lo, + .size = size, + .shift = shift, + .flags = flags, + }; + pool->entry = pcalloc(pool, 1, sizeof(tee_mm_entry_t)); if (pool->entry == NULL) return false;