mempool:Need check mpool is NULL

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-04-07 16:42:16 +08:00 committed by Xiang Xiao
parent 8f92695ee1
commit e6bf25a714

View File

@ -754,6 +754,12 @@ mempool_multiple_mallinfo(FAR struct mempool_multiple_s *mpool)
struct mallinfo info; struct mallinfo info;
size_t i; size_t i;
if (mpool == NULL)
{
memset(&info, 0, sizeof(struct mallinfo));
return info;
}
memset(&info, 0, sizeof(struct mallinfo)); memset(&info, 0, sizeof(struct mallinfo));
nxrmutex_lock(&mpool->lock); nxrmutex_lock(&mpool->lock);
@ -838,6 +844,11 @@ void mempool_multiple_memdump(FAR struct mempool_multiple_s *mpool,
{ {
size_t i; size_t i;
if (mpool == NULL)
{
return;
}
for (i = 0; i < mpool->npools; i++) for (i = 0; i < mpool->npools; i++)
{ {
mempool_memdump(mpool->pools + i, dump); mempool_memdump(mpool->pools + i, dump);
@ -859,7 +870,10 @@ void mempool_multiple_deinit(FAR struct mempool_multiple_s *mpool)
{ {
size_t i; size_t i;
DEBUGASSERT(mpool != NULL); if (mpool == NULL)
{
return;
}
for (i = 0; i < mpool->npools; i++) for (i = 0; i < mpool->npools; i++)
{ {