Thread (6 messages) 6 messages, 6 authors, 2023-11-02

Re: [PATCH net] net: page_pool: add missing free_percpu when page_pool_init fail

From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Date: 2023-11-01 11:11:56
Also in: lkml

On Mon, 30 Oct 2023 at 11:17, Jijie Shao [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Jian Shen <shenjian15@huawei.com>

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 <shenjian15@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 net/core/page_pool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 77cb75e63aca..31f923e7b5c4 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);

--
2.30.0
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help