From e6bf25a714eb8f06b2566d486dd46c32ea2d96fd Mon Sep 17 00:00:00 2001 From: anjiahao Date: Sun, 7 Apr 2024 16:42:16 +0800 Subject: [PATCH] mempool:Need check mpool is NULL Signed-off-by: anjiahao --- mm/mempool/mempool_multiple.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mm/mempool/mempool_multiple.c b/mm/mempool/mempool_multiple.c index 412c566dd9..7008aa6987 100644 --- a/mm/mempool/mempool_multiple.c +++ b/mm/mempool/mempool_multiple.c @@ -754,6 +754,12 @@ mempool_multiple_mallinfo(FAR struct mempool_multiple_s *mpool) struct mallinfo info; size_t i; + if (mpool == NULL) + { + memset(&info, 0, sizeof(struct mallinfo)); + return info; + } + memset(&info, 0, sizeof(struct mallinfo)); nxrmutex_lock(&mpool->lock); @@ -838,6 +844,11 @@ void mempool_multiple_memdump(FAR struct mempool_multiple_s *mpool, { size_t i; + if (mpool == NULL) + { + return; + } + for (i = 0; i < mpool->npools; i++) { mempool_memdump(mpool->pools + i, dump); @@ -859,7 +870,10 @@ void mempool_multiple_deinit(FAR struct mempool_multiple_s *mpool) { size_t i; - DEBUGASSERT(mpool != NULL); + if (mpool == NULL) + { + return; + } for (i = 0; i < mpool->npools; i++) {