From d83ae9c923b2b271ffd2a86279dad91c7713146d Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 15 Oct 2018 10:00:17 -0700 Subject: tlsf_malloc: dummy_malloc: Share code for calloc() Calloc() implementation for TLSF does not correctly check for malloc() failure which can result in a NULL pointer exception when trying to calloc() extra large buffers. Since both TLSF and dummy malloc implementations of calloc() are exactly the same, pick implementation for the latter (which does aforementioned check) and share it between the two. Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- common/tlsf_malloc.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'common/tlsf_malloc.c') diff --git a/common/tlsf_malloc.c b/common/tlsf_malloc.c index a3541d8256..aa3ab23975 100644 --- a/common/tlsf_malloc.c +++ b/common/tlsf_malloc.c @@ -39,22 +39,6 @@ void *malloc(size_t bytes) } EXPORT_SYMBOL(malloc); -/* - * calloc calls malloc, then zeroes out the allocated chunk. - */ -void *calloc(size_t n, size_t elem_size) -{ - void *mem; - size_t sz; - - sz = n * elem_size; - mem = malloc(sz); - memset(mem, 0, sz); - - return mem; -} -EXPORT_SYMBOL(calloc); - void free(void *mem) { tlsf_free(tlsf_mem_pool, mem); -- cgit v1.2.3