[coverity] tlsf.c tlsf_malloc guard against empty mempool

on error mp could still be NULL

Change-Id: Ic86571a7d5d0c3586d2be00b45251f03b1be3fca
This commit is contained in:
William Wilgus 2024-06-02 16:08:06 -04:00
parent 82dcf32736
commit 2903a8e8ac

View file

@ -695,7 +695,7 @@ void destroy_memory_pool(void *mem_pool)
void *tlsf_malloc(size_t size)
{
/******************************************************************/
void *ret;
void *ret = NULL;
#if USE_MMAP || USE_SBRK || defined(ROCKBOX)
if (!mp) {
@ -710,12 +710,14 @@ void *tlsf_malloc(size_t size)
init_memory_pool(area_size, area);
}
#endif
if (mp)
{
TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
ret = malloc_ex(size, mp);
TLSF_RELEASE_LOCK(&((tlsf_t *)mp)->lock);
}
return ret;
}