public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net: libwx: handle page_pool_dev_alloc_pages error
@ 2025-04-07 18:49 Chenyuan Yang
  2025-04-08  2:44 ` Joe Damato
  2025-04-08 23:24 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Chenyuan Yang @ 2025-04-07 18:49 UTC (permalink / raw)
  To: jiawenwu, mengyuanlou, andrew+netdev, davem, edumazet, kuba,
	pabeni, horms, duanqiangwen, dlemoal, jdamato
  Cc: netdev, linux-kernel, Chenyuan Yang

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")
---
 drivers/net/ethernet/wangxun/libwx/wx_lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
index 00b0b318df27..d567443b1b20 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] net: libwx: handle page_pool_dev_alloc_pages error
  2025-04-07 18:49 [PATCH v2] net: libwx: handle page_pool_dev_alloc_pages error Chenyuan Yang
@ 2025-04-08  2:44 ` Joe Damato
  2025-04-08 23:24 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Damato @ 2025-04-08  2:44 UTC (permalink / raw)
  To: Chenyuan Yang
  Cc: jiawenwu, mengyuanlou, andrew+netdev, davem, edumazet, kuba,
	pabeni, horms, duanqiangwen, dlemoal, netdev, linux-kernel

On Mon, Apr 07, 2025 at 01:49:52PM -0500, Chenyuan Yang wrote:
> 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")
> ---
>  drivers/net/ethernet/wangxun/libwx/wx_lib.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Joe Damato <jdamato@fastly.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] net: libwx: handle page_pool_dev_alloc_pages error
  2025-04-07 18:49 [PATCH v2] net: libwx: handle page_pool_dev_alloc_pages error Chenyuan Yang
  2025-04-08  2:44 ` Joe Damato
@ 2025-04-08 23:24 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-08 23:24 UTC (permalink / raw)
  To: Chenyuan Yang
  Cc: jiawenwu, mengyuanlou, andrew+netdev, davem, edumazet, kuba,
	pabeni, horms, duanqiangwen, dlemoal, jdamato, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  7 Apr 2025 13:49:52 -0500 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [v2] net: libwx: handle page_pool_dev_alloc_pages error
    https://git.kernel.org/netdev/net/c/7f1ff1b38a7c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-08 23:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07 18:49 [PATCH v2] net: libwx: handle page_pool_dev_alloc_pages error Chenyuan Yang
2025-04-08  2:44 ` Joe Damato
2025-04-08 23:24 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox