diff options
-rw-r--r-- | lib/libutee/tee_api.c | 21 | ||||
-rw-r--r-- | lib/libutils/isoc/bget.c | 5 | ||||
-rw-r--r-- | mk/config.mk | 5 |
3 files changed, 17 insertions, 14 deletions
diff --git a/lib/libutee/tee_api.c b/lib/libutee/tee_api.c index 3eb87148..4d508db2 100644 --- a/lib/libutee/tee_api.c +++ b/lib/libutee/tee_api.c @@ -29,9 +29,9 @@ #include <string.h> #include <tee_api.h> -#include <utee_syscalls.h> +#include <tee_internal_api_extensions.h> #include <user_ta_header.h> -#include "tee_user_mem.h" +#include <utee_syscalls.h> #include "tee_api_private.h" static const void *tee_api_instance_data; @@ -312,21 +312,24 @@ void TEE_GetREETime(TEE_Time *time) void *TEE_Malloc(uint32_t len, uint32_t hint) { - return tee_user_mem_alloc(len, hint); + if (hint == TEE_MALLOC_FILL_ZERO) + return calloc(1, len); + else if (hint == TEE_USER_MEM_HINT_NO_FILL_ZERO) + return malloc(len); + + EMSG("Invalid hint %#" PRIx32, hint); + + return NULL; } void *TEE_Realloc(void *buffer, uint32_t newSize) { - /* - * GP TEE Internal API specifies newSize as 'uint32_t'. - * use unsigned 'size_t' type. it is at least 32bit! - */ - return tee_user_mem_realloc((void *)buffer, (size_t) newSize); + return realloc(buffer, newSize); } void TEE_Free(void *buffer) { - tee_user_mem_free(buffer); + free(buffer); } /* Cache maintenance support (TA requires the CACHE_MAINTENANCE property) */ diff --git a/lib/libutils/isoc/bget.c b/lib/libutils/isoc/bget.c index 33a7a695..b29e13ea 100644 --- a/lib/libutils/isoc/bget.c +++ b/lib/libutils/isoc/bget.c @@ -823,6 +823,11 @@ void *bgetr(buf, size, poolset) assert(osize > 0); V memcpy((char *) nbuf, (char *) buf, /* Copy the data */ (MemSize) ((size < osize) ? size : osize)); +#ifndef __KERNEL__ + /* User space reallocations are always zeroed */ + if (size > osize) + V memset((char *) nbuf + osize, 0, size - osize); +#endif brel(buf, poolset); return nbuf; } diff --git a/mk/config.mk b/mk/config.mk index 70c998a6..fcab13c3 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -59,11 +59,6 @@ CFG_TEE_TA_LOG_LEVEL ?= 1 # CFG_TEE_TA_LOG_LEVEL. Otherwise, they are not output at all CFG_TEE_CORE_TA_TRACE ?= y -# If 1, enable debug features in TA memory allocation. -# Debug features include check of buffer overflow, statistics, mark/check heap -# feature. -CFG_TEE_CORE_USER_MEM_DEBUG ?= 1 - # If y, enable the memory leak detection feature in the bget memory allocator. # When this feature is enabled, calling mdbg_check(1) will print a list of all # the currently allocated buffers and the location of the allocation (file and |