mirror of
https://github.com/apache/nuttx.git
synced 2026-05-24 16:11:56 +08:00
mm: fix kasan report error when delay free is enabled
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
+12
-1
@@ -102,7 +102,18 @@ void mm_delayfree(FAR struct mm_heap_s *heap, FAR void *mem, bool delay)
|
||||
|
||||
nodesize = mm_malloc_size(heap, mem);
|
||||
#ifdef CONFIG_MM_FILL_ALLOCATIONS
|
||||
memset(mem, MM_FREE_MAGIC, nodesize);
|
||||
#if CONFIG_MM_FREE_DELAYCOUNT_MAX > 0
|
||||
/* If delay free is enabled, a memory node will be freed twice.
|
||||
* The first time is to add the node to the delay list, and the second
|
||||
* time is to actually free the node. Therefore, we only colorize the
|
||||
* memory node the first time, when `delay` is set to true.
|
||||
*/
|
||||
|
||||
if (delay)
|
||||
#endif
|
||||
{
|
||||
memset(mem, MM_FREE_MAGIC, nodesize);
|
||||
}
|
||||
#endif
|
||||
|
||||
kasan_poison(mem, nodesize);
|
||||
|
||||
+12
-1
@@ -595,7 +595,18 @@ static void mm_delayfree(FAR struct mm_heap_s *heap, FAR void *mem,
|
||||
size_t size = mm_malloc_size(heap, mem);
|
||||
UNUSED(size);
|
||||
#ifdef CONFIG_MM_FILL_ALLOCATIONS
|
||||
memset(mem, MM_FREE_MAGIC, size);
|
||||
#if CONFIG_MM_FREE_DELAYCOUNT_MAX > 0
|
||||
/* If delay free is enabled, a memory node will be freed twice.
|
||||
* The first time is to add the node to the delay list, and the second
|
||||
* time is to actually free the node. Therefore, we only colorize the
|
||||
* memory node the first time, when `delay` is set to true.
|
||||
*/
|
||||
|
||||
if (delay)
|
||||
#endif
|
||||
{
|
||||
memset(mem, MM_FREE_MAGIC, nodesize);
|
||||
}
|
||||
#endif
|
||||
|
||||
kasan_poison(mem, size);
|
||||
|
||||
Reference in New Issue
Block a user