From df2925cf13bf94de08baddfafc056804e3437294 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Thu, 16 Feb 2023 12:28:54 +0800 Subject: [PATCH] mempool:fix bug, use incorrect free in mempool init Signed-off-by: anjiahao --- mm/mempool/mempool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/mempool/mempool.c b/mm/mempool/mempool.c index ee65d94b74..c0dc04e7d6 100644 --- a/mm/mempool/mempool.c +++ b/mm/mempool/mempool.c @@ -174,7 +174,11 @@ int mempool_init(FAR struct mempool_s *pool, FAR const char *name) base = pool->alloc(pool, size); if (base == NULL) { - mempool_free(pool, pool->ibase); + if (pool->ibase) + { + pool->free(pool, pool->ibase); + } + return -ENOMEM; }