mempool:fix memdump leak will hang on spinlock

root cuase is getpid use spinlock
can read mempool nodes without needing spinlock protection.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-06-25 11:22:44 +08:00 committed by Xiang Xiao
parent 73f506b65f
commit 7c34ece5d6

View File

@ -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;
}