diff --git a/mm/mempool/mempool.c b/mm/mempool/mempool.c index 624ce291cb..89b3f80e24 100644 --- a/mm/mempool/mempool.c +++ b/mm/mempool/mempool.c @@ -397,16 +397,17 @@ retry: pool->nalloc++; spin_unlock_irqrestore(&pool->lock, flags); - blk = kasan_unpoison(blk, pool->blocksize); -#ifdef CONFIG_MM_FILL_ALLOCATIONS - memset(blk, MM_ALLOC_MAGIC, pool->blocksize); -#endif #if CONFIG_MM_BACKTRACE >= 0 mempool_add_backtrace(pool, (FAR struct mempool_backtrace_s *) ((FAR char *)blk + pool->blocksize)); #endif + blk = kasan_unpoison(blk, pool->blocksize); +#ifdef CONFIG_MM_FILL_ALLOCATIONS + memset(blk, MM_ALLOC_MAGIC, pool->blocksize); +#endif + return blk; }