diff mbox series

net: libwx: handle page_pool_dev_alloc_pages error

Message ID 20250406192351.3850007-1-chenyuan0y@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: libwx: handle page_pool_dev_alloc_pages error | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 14 this patch: 14
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-04-07--00-00 (tests: 900)

Commit Message

Chenyuan Yang April 6, 2025, 7:23 p.m. UTC
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").

Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
---
 drivers/net/ethernet/wangxun/libwx/wx_lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michal Swiatkowski April 7, 2025, 5:32 a.m. UTC | #1
On Sun, Apr 06, 2025 at 02:23:51PM -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").
> 
> Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
> ---
>  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;

Thanks for fixing, it is fine, however you need to add fixes tag.
Probably:
Fixes: 3c47e8ae113a ("net: libwx: Support to receive packets in NAPI")

> -- 
> 2.34.1
Chenyuan Yang April 7, 2025, 2:43 p.m. UTC | #2
Hi Michal,

Thank you for your reply and suggestions.
Would you like me to send a new patch (for example, [Patch v2]) with
the "Fix" tag included?

-Chenyuan

On Mon, Apr 7, 2025 at 12:32 AM Michal Swiatkowski
<michal.swiatkowski@linux.intel.com> wrote:
>
> On Sun, Apr 06, 2025 at 02:23:51PM -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").
> >
> > Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
> > ---
> >  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;
>
> Thanks for fixing, it is fine, however you need to add fixes tag.
> Probably:
> Fixes: 3c47e8ae113a ("net: libwx: Support to receive packets in NAPI")
>
> > --
> > 2.34.1
Jakub Kicinski April 7, 2025, 5:33 p.m. UTC | #3
On Mon, 7 Apr 2025 09:43:56 -0500 Chenyuan Yang wrote:
> Hi Michal,
> 
> Thank you for your reply and suggestions.
> Would you like me to send a new patch (for example, [Patch v2]) with
> the "Fix" tag included?

Yes, and please don't top post.
diff mbox series

Patch

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;