Skip to content

Commit

Permalink
mm: mm_malloc_size Switching using kasan_bypass_save
Browse files Browse the repository at this point in the history
Because it will be called in mm_lock and outside mm_unlock, it needs to keep the same state as before closing.

Signed-off-by: wangmingrong1 <[email protected]>
  • Loading branch information
W-M-R committed Jan 14, 2025
1 parent 5a66de8 commit 1cc26f1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mm/mm_heap/mm_malloc_size.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <assert.h>
#include <debug.h>

#include <nuttx/mm/kasan.h>
#include <nuttx/mm/mm.h>

#include "mm_heap/mm.h"
Expand All @@ -40,10 +41,14 @@
size_t mm_malloc_size(FAR struct mm_heap_s *heap, FAR void *mem)
{
FAR struct mm_freenode_s *node;
size_t size;
bool mte;

mte = kasan_bypass_save();
#ifdef CONFIG_MM_HEAP_MEMPOOL
if (heap->mm_mpool)
{
ssize_t size = mempool_multiple_alloc_size(heap->mm_mpool, mem);
size = mempool_multiple_alloc_size(heap->mm_mpool, mem);
if (size >= 0)
{
return size;
Expand All @@ -66,5 +71,8 @@ size_t mm_malloc_size(FAR struct mm_heap_s *heap, FAR void *mem)

DEBUGASSERT(MM_NODE_IS_ALLOC(node));

return MM_SIZEOF_NODE(node) - MM_ALLOCNODE_OVERHEAD;
size = MM_SIZEOF_NODE(node) - MM_ALLOCNODE_OVERHEAD;

kasan_bypass_restore(mte);
return size;
}

0 comments on commit 1cc26f1

Please sign in to comment.