Skip to content

Commit

Permalink
net: libwx: handle page_pool_dev_alloc_pages error
Browse files Browse the repository at this point in the history
page_pool_dev_alloc_pages could return NULL. There was a WARN_ON(!page)
but it would still proceed to use the NULL pointer and then crash.

This is similar to commit 001ba09
("net: fec: handle page_pool_dev_alloc_pages error").

This is found by our static analysis tool KNighter.

Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
Fixes: 3c47e8a ("net: libwx: Support to receive packets in NAPI")
Reviewed-by: Joe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/20250407184952.2111299-1-chenyuan0y@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Chenyuan Yang authored and Jakub Kicinski committed Apr 8, 2025
1 parent dd17a7f commit 7f1ff1b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/wangxun/libwx/wx_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ static bool wx_alloc_mapped_page(struct wx_ring *rx_ring,
return true;

page = page_pool_dev_alloc_pages(rx_ring->page_pool);
WARN_ON(!page);
if (unlikely(!page))
return false;
dma = page_pool_get_dma_addr(page);

bi->page_dma = dma;
Expand Down

0 comments on commit 7f1ff1b

Please sign in to comment.