[net RFC v1 1/1] page_pool: fix NULL dereference crash

From: Colin Foster
Date: Fri Jan 21 2022 - 19:57:23 EST


Check for the existence of page pool params before dereferencing. This can
cause crashes in certain conditions.

Fixes: 35b2e549894b ("page_pool: Add callback to init pages when they are
allocated")

Signed-off-by: Colin Foster <colin.foster@xxxxxxxxxxxxxxxx>
---
net/core/page_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index bd62c01a2ec3..641f849c95e7 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -213,7 +213,7 @@ static void page_pool_set_pp_info(struct page_pool *pool,
{
page->pp = pool;
page->pp_magic |= PP_SIGNATURE;
- if (pool->p.init_callback)
+ if (pool->p && pool->p.init_callback)
pool->p.init_callback(page, pool->p.init_arg);
}

--
2.25.1