mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
mm: fix memory corruption when loop create/exit thread in SMP mode
Root casue: when do thread exit, need add free stack operation to mm_delaylist, but in SMP mode, CPU0 thread1 exit, at this time, CPU1 call malloc and free mm_delaylist. Fix: Divide mm_delaylist for per CPU in SMP mode. Change-Id: Ibf7d04614ea2f99fb5b506356b7346a0d94f0590 Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
@@ -197,20 +197,10 @@ void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
||||
|
||||
/* Set up global variables */
|
||||
|
||||
heap_impl->mm_heapsize = 0;
|
||||
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
heap_impl->mm_nregions = 0;
|
||||
#endif
|
||||
|
||||
/* Initialize mm_delaylist */
|
||||
|
||||
heap_impl->mm_delaylist = NULL;
|
||||
memset(heap_impl, 0, sizeof(struct mm_heap_impl_s));
|
||||
|
||||
/* Initialize the node array */
|
||||
|
||||
memset(heap_impl->mm_nodelist, 0,
|
||||
sizeof(struct mm_freenode_s) * MM_NNODES);
|
||||
for (i = 1; i < MM_NNODES; i++)
|
||||
{
|
||||
heap_impl->mm_nodelist[i - 1].flink = &heap_impl->mm_nodelist[i];
|
||||
|
||||
Reference in New Issue
Block a user