summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbernard <[email protected]>2017-10-31 11:38:28 +0800
committerbernard <[email protected]>2017-10-31 11:38:28 +0800
commitc7330863545342bf9ddcee67d221957688129558 (patch)
tree51b484dfe63405f78dae66738861eead70c4ff07
parentd615bebb7c22c3541962934469380a0f993e7d74 (diff)
[Kernel] Fix sem_release twice issue in slab.
-rw-r--r--src/slab.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/slab.c b/src/slab.c
index 14a2c784b5..5e6a204896 100644
--- a/src/slab.c
+++ b/src/slab.c
@@ -616,7 +616,10 @@ void *rt_malloc(rt_size_t size)
/* allocate a zone from page */
z = rt_page_alloc(zone_size / RT_MM_PAGE_SIZE);
if (z == RT_NULL)
- goto fail;
+ {
+ chunk = RT_NULL;
+ goto __exit;
+ }
/* lock heap */
rt_sem_take(&heap_sem, RT_WAITING_FOREVER);
@@ -672,15 +675,10 @@ void *rt_malloc(rt_size_t size)
done:
rt_sem_release(&heap_sem);
-
RT_OBJECT_HOOK_CALL(rt_malloc_hook, ((char *)chunk, size));
+__exit:
return chunk;
-
-fail:
- rt_sem_release(&heap_sem);
-
- return RT_NULL;
}
RTM_EXPORT(rt_malloc);