diff --git a/mm/mm_heap/mm_free.c b/mm/mm_heap/mm_free.c index 6848ad3ab8b..013c1551425 100644 --- a/mm/mm_heap/mm_free.c +++ b/mm/mm_heap/mm_free.c @@ -116,7 +116,8 @@ void mm_delayfree(FAR struct mm_heap_s *heap, FAR void *mem, bool delay) /* Map the memory chunk into a free node */ - node = (FAR struct mm_freenode_s *)((FAR char *)mem - MM_SIZEOF_ALLOCNODE); + node = (FAR struct mm_freenode_s *) + ((FAR char *)kasan_reset_tag(mem) - MM_SIZEOF_ALLOCNODE); nodesize = MM_SIZEOF_NODE(node); /* Sanity check against double-frees */ diff --git a/mm/mm_heap/mm_memalign.c b/mm/mm_heap/mm_memalign.c index aa0621889fe..cdf6338b1ef 100644 --- a/mm/mm_heap/mm_memalign.c +++ b/mm/mm_heap/mm_memalign.c @@ -141,6 +141,8 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment, kasan_poison((FAR void *)rawchunk, mm_malloc_size(heap, (FAR void *)rawchunk)); + rawchunk = (uintptr_t)kasan_reset_tag((FAR void *)rawchunk); + /* We need to hold the MM mutex while we muck with the chunks and * nodelist. */ diff --git a/mm/mm_heap/mm_realloc.c b/mm/mm_heap/mm_realloc.c index 13fc8495418..d41619a66ad 100644 --- a/mm/mm_heap/mm_realloc.c +++ b/mm/mm_heap/mm_realloc.c @@ -132,7 +132,7 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem, /* Map the memory chunk into an allocated node structure */ oldnode = (FAR struct mm_allocnode_s *) - ((FAR char *)oldmem - MM_SIZEOF_ALLOCNODE); + ((FAR char *)kasan_reset_tag(oldmem) - MM_SIZEOF_ALLOCNODE); /* We need to hold the MM mutex while we muck with the nodelist. */