Skip to content

Commit 8ffbd16

Browse files
IronShenPaolo Abeni
authored andcommitted
net: page_pool: add missing free_percpu when page_pool_init fail
When ptr_ring_init() returns failure in page_pool_init(), free_percpu() is not called to free pool->recycle_stats, which may cause memory leak. Fixes: ad6fa1e ("page_pool: Add recycle stats") Signed-off-by: Jian Shen <[email protected]> Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Yunsheng Lin <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Reviewed-by: Somnath Kotur <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent f55d8e6 commit 8ffbd16

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/core/page_pool.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,12 @@ static int page_pool_init(struct page_pool *pool,
217217
return -ENOMEM;
218218
#endif
219219

220-
if (ptr_ring_init(&pool->ring, ring_qsize, GFP_KERNEL) < 0)
220+
if (ptr_ring_init(&pool->ring, ring_qsize, GFP_KERNEL) < 0) {
221+
#ifdef CONFIG_PAGE_POOL_STATS
222+
free_percpu(pool->recycle_stats);
223+
#endif
221224
return -ENOMEM;
225+
}
222226

223227
atomic_set(&pool->pages_state_release_cnt, 0);
224228

0 commit comments

Comments
 (0)