This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch releases/12.7
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit cff121bc230bcdddefd44f49aa085ea319963423
Author: yinshengkai <yinsheng...@xiaomi.com>
AuthorDate: Tue Nov 14 22:19:52 2023 +0800

    mm: fix memory statistics error
    
    Signed-off-by: yinshengkai <yinsheng...@xiaomi.com>
    Signed-off-by: Neo Xu <neo.xu1...@gmail.com>
---
 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);
         }

Reply via email to