[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3ced7d6b-0f7c-468c-81be-198a604a0efe@broadcom.com>
Date: Tue, 13 Feb 2024 10:56:29 -0800
From: Justin Chen <justin.chen@...adcom.com>
To: Florian Fainelli <florian.fainelli@...adcom.com>, netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
"open list:BROADCOM ASP 2.0 ETHERNET DRIVER"
<bcm-kernel-feedback-list@...adcom.com>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net] net: bcmasp: Handle RX buffer allocation failure
On 2/13/24 9:33 AM, Florian Fainelli wrote:
> The buffer_pg variable needs to hold an order-5 allocation (32 x
> PAGE_SIZE) which, under memory pressure may fail to be allocated. Deal
> with that error condition properly to avoid doing a NULL pointer
> de-reference in the subsequent call to dma_map_page().
>
> In addition, the err_reclaim_tx error label in bcmasp_netif_init() needs
> to ensure that the TX NAPI object is properly deleted, otherwise
> unregister_netdev() will spin forever attempting to test and clear
> the NAPI_STATE_HASHED bit.
>
> Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
> Signed-off-by: Florian Fainelli <florian.fainelli@...adcom.com>
Reviewed-by: Justin Chen <justin.chen@...adcom.com>
> ---
> drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
> index 53e542881255..f59557b0cd51 100644
> --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
> +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
> @@ -684,6 +684,8 @@ static int bcmasp_init_rx(struct bcmasp_intf *intf)
>
> intf->rx_buf_order = get_order(RING_BUFFER_SIZE);
> buffer_pg = alloc_pages(GFP_KERNEL, intf->rx_buf_order);
> + if (!buffer_pg)
> + return -ENOMEM;
>
> dma = dma_map_page(kdev, buffer_pg, 0, RING_BUFFER_SIZE,
> DMA_FROM_DEVICE);
> @@ -1092,6 +1094,7 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect)
> return 0;
>
> err_reclaim_tx:
> + netif_napi_del(&intf->tx_napi);
> bcmasp_reclaim_free_all_tx(intf);
> err_phy_disconnect:
> if (phydev)
Download attachment "smime.p7s" of type "application/pkcs7-signature" (4206 bytes)
Powered by blists - more mailing lists