diff --git a/mm/mempool/mempool.c b/mm/mempool/mempool.c index d0cf1f5e43..e874db9e26 100644 --- a/mm/mempool/mempool.c +++ b/mm/mempool/mempool.c @@ -533,7 +533,6 @@ mempool_info_task(FAR struct mempool_s *pool, FAR const struct malltask *task) { size_t blocksize = MEMPOOL_REALBLOCKSIZE(pool); - irqstate_t flags = spin_lock_irqsave(&pool->lock); struct mallinfo_task info = { 0, 0 @@ -541,8 +540,11 @@ mempool_info_task(FAR struct mempool_s *pool, if (task->pid == PID_MM_FREE) { + irqstate_t flags = spin_lock_irqsave(&pool->lock); size_t count = sq_count(&pool->queue) + sq_count(&pool->iqueue); + + spin_unlock_irqrestore(&pool->lock, flags); info.aordblks += count; info.uordblks += count * blocksize; } @@ -558,7 +560,6 @@ mempool_info_task(FAR struct mempool_s *pool, } #endif - spin_unlock_irqrestore(&pool->lock, flags); return info; }