mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
[coverity] tlsf.c tlsf_malloc guard against empty mempool
on error mp could still be NULL Change-Id: Ic86571a7d5d0c3586d2be00b45251f03b1be3fca
This commit is contained in:
parent
82dcf32736
commit
2903a8e8ac
1 changed files with 7 additions and 5 deletions
|
@ -695,7 +695,7 @@ void destroy_memory_pool(void *mem_pool)
|
||||||
void *tlsf_malloc(size_t size)
|
void *tlsf_malloc(size_t size)
|
||||||
{
|
{
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
void *ret;
|
void *ret = NULL;
|
||||||
|
|
||||||
#if USE_MMAP || USE_SBRK || defined(ROCKBOX)
|
#if USE_MMAP || USE_SBRK || defined(ROCKBOX)
|
||||||
if (!mp) {
|
if (!mp) {
|
||||||
|
@ -710,12 +710,14 @@ void *tlsf_malloc(size_t size)
|
||||||
init_memory_pool(area_size, area);
|
init_memory_pool(area_size, area);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (mp)
|
||||||
|
{
|
||||||
|
TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
|
||||||
|
|
||||||
TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
|
ret = malloc_ex(size, mp);
|
||||||
|
|
||||||
ret = malloc_ex(size, mp);
|
TLSF_RELEASE_LOCK(&((tlsf_t *)mp)->lock);
|
||||||
|
}
|
||||||
TLSF_RELEASE_LOCK(&((tlsf_t *)mp)->lock);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue