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:
ligd
2021-06-21 16:20:44 +08:00
committed by Xiang Xiao
parent 554310bd78
commit aa43a0215d
5 changed files with 23 additions and 22 deletions
+1 -11
View File
@@ -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];