From cff121bc230bcdddefd44f49aa085ea319963423 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Tue, 14 Nov 2023 22:19:52 +0800 Subject: [PATCH] mm: fix memory statistics error Signed-off-by: yinshengkai Signed-off-by: Neo Xu --- mm/tlsf/mm_tlsf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c index 8296777927..6962eed550 100644 --- a/mm/tlsf/mm_tlsf.c +++ b/mm/tlsf/mm_tlsf.c @@ -500,10 +500,6 @@ static void mm_delayfree(FAR struct mm_heap_s *heap, FAR void *mem, kasan_poison(mem, size); - /* Update heap statistics */ - - heap->mm_curused -= size; - /* Pass, return to the tlsf pool */ if (delay) @@ -512,6 +508,9 @@ static void mm_delayfree(FAR struct mm_heap_s *heap, FAR void *mem, } else { + /* Update heap statistics */ + + heap->mm_curused -= mm_malloc_size(heap, mem); sched_note_heap(false, heap, mem, size); tlsf_free(heap->mm_tlsf, mem); }