summaryrefslogtreecommitdiffstats
path: root/common/tlsf_malloc.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-04-30 13:31:29 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-04-30 13:31:29 +0200
commite652753f9570afd688d8b62c8d8f9b321b901d7b (patch)
tree4320c7c4df32185d3a6f7ee4032c15270f0a7582 /common/tlsf_malloc.c
parentcac75c0f2397f760d4d346219b2b9249b45872f1 (diff)
downloadbarebox-e652753f9570afd688d8b62c8d8f9b321b901d7b.tar.gz
tlsf_malloc: return valid pointer for malloc(0)
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/tlsf_malloc.c')
-rw-r--r--common/tlsf_malloc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/tlsf_malloc.c b/common/tlsf_malloc.c
index 2fe443b..8143d66 100644
--- a/common/tlsf_malloc.c
+++ b/common/tlsf_malloc.c
@@ -33,6 +33,13 @@ extern tlsf_pool tlsf_mem_pool;
void *malloc(size_t bytes)
{
+ /*
+ * tlsf_malloc returns NULL for zero bytes, we instead want
+ * to have a valid pointer.
+ */
+ if (!bytes)
+ bytes = 1;
+
return tlsf_malloc(tlsf_mem_pool, bytes);
}
EXPORT_SYMBOL(malloc);