]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: libwx: handle page_pool_dev_alloc_pages error
authorChenyuan Yang <chenyuan0y@gmail.com>
Mon, 7 Apr 2025 18:49:52 +0000 (13:49 -0500)
committerJakub Kicinski <kuba@kernel.org>
Tue, 8 Apr 2025 23:17:30 +0000 (16:17 -0700)
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 001ba0902046
("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: 3c47e8ae113a ("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>
drivers/net/ethernet/wangxun/libwx/wx_lib.c

index 6ebefa31ece1c5eee7cd7e96cf7542bde8bc7a73..e69eaa65e0de8514070e61f517d47b4203bec5eb 100644 (file)
@@ -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;