[Kernel] Fix sem_release twice issue in slab.
This commit is contained in:
parent
d615bebb7c
commit
c733086354
12
src/slab.c
12
src/slab.c
|
@ -616,7 +616,10 @@ void *rt_malloc(rt_size_t size)
|
||||||
/* allocate a zone from page */
|
/* allocate a zone from page */
|
||||||
z = rt_page_alloc(zone_size / RT_MM_PAGE_SIZE);
|
z = rt_page_alloc(zone_size / RT_MM_PAGE_SIZE);
|
||||||
if (z == RT_NULL)
|
if (z == RT_NULL)
|
||||||
goto fail;
|
{
|
||||||
|
chunk = RT_NULL;
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* lock heap */
|
/* lock heap */
|
||||||
rt_sem_take(&heap_sem, RT_WAITING_FOREVER);
|
rt_sem_take(&heap_sem, RT_WAITING_FOREVER);
|
||||||
|
@ -672,15 +675,10 @@ void *rt_malloc(rt_size_t size)
|
||||||
|
|
||||||
done:
|
done:
|
||||||
rt_sem_release(&heap_sem);
|
rt_sem_release(&heap_sem);
|
||||||
|
|
||||||
RT_OBJECT_HOOK_CALL(rt_malloc_hook, ((char *)chunk, size));
|
RT_OBJECT_HOOK_CALL(rt_malloc_hook, ((char *)chunk, size));
|
||||||
|
|
||||||
|
__exit:
|
||||||
return chunk;
|
return chunk;
|
||||||
|
|
||||||
fail:
|
|
||||||
rt_sem_release(&heap_sem);
|
|
||||||
|
|
||||||
return RT_NULL;
|
|
||||||
}
|
}
|
||||||
RTM_EXPORT(rt_malloc);
|
RTM_EXPORT(rt_malloc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue