From e053dcc9f4e2406d46db32cd7dd945771781335d Mon Sep 17 00:00:00 2001 From: anjiahao Date: Fri, 11 Aug 2023 14:42:59 +0800 Subject: [PATCH] mempool:add check for double free check for mempool free Signed-off-by: anjiahao --- mm/mempool/mempool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/mempool/mempool.c b/mm/mempool/mempool.c index f97913e1a1..145ca4588d 100644 --- a/mm/mempool/mempool.c +++ b/mm/mempool/mempool.c @@ -304,6 +304,9 @@ void mempool_free(FAR struct mempool_s *pool, FAR void *blk) FAR struct mempool_backtrace_s *buf = (FAR struct mempool_backtrace_s *)((FAR char *)blk + pool->blocksize); + /* Check double free */ + + DEBUGASSERT(list_in_list(&buf->node)); list_delete(&buf->node); #else pool->nalloc--;