From: Jian Shen Date: Mon, 30 Oct 2023 09:12:56 +0000 (+0800) Subject: net: page_pool: add missing free_percpu when page_pool_init fail X-Git-Tag: v6.6.7~1076 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c137b1cd60f1124c830b0ef75324fd14d1d6685;p=platform%2Fkernel%2Flinux-starfive.git net: page_pool: add missing free_percpu when page_pool_init fail [ Upstream commit 8ffbd1669ed1d58939d6e878dffaa2f60bf961a4 ] 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: ad6fa1e1ab1b ("page_pool: Add recycle stats") Signed-off-by: Jian Shen Signed-off-by: Jijie Shao Reviewed-by: Yunsheng Lin Reviewed-by: Jiri Pirko Reviewed-by: Somnath Kotur Reviewed-by: Ilias Apalodimas Link: https://lore.kernel.org/r/20231030091256.2915394-1-shaojijie@huawei.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 77cb75e..31f923e 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -221,8 +221,12 @@ static int page_pool_init(struct page_pool *pool, return -ENOMEM; #endif - if (ptr_ring_init(&pool->ring, ring_qsize, GFP_KERNEL) < 0) + if (ptr_ring_init(&pool->ring, ring_qsize, GFP_KERNEL) < 0) { +#ifdef CONFIG_PAGE_POOL_STATS + free_percpu(pool->recycle_stats); +#endif return -ENOMEM; + } atomic_set(&pool->pages_state_release_cnt, 0);