Skip to content

Commit e5b2e81

Browse files
ffainelliPaolo Abeni
authored andcommitted
net: bcmasp: Handle RX buffer allocation failure
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: 490cb41 ("net: bcmasp: Add support for ASP2.0 Ethernet controller") Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com> Reviewed-by: Justin Chen <justin.chen@broadcom.com> Link: https://lore.kernel.org/r/20240213173339.3438713-1-florian.fainelli@broadcom.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent d74b23d commit e5b2e81

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,8 @@ static int bcmasp_init_rx(struct bcmasp_intf *intf)
684684

685685
intf->rx_buf_order = get_order(RING_BUFFER_SIZE);
686686
buffer_pg = alloc_pages(GFP_KERNEL, intf->rx_buf_order);
687+
if (!buffer_pg)
688+
return -ENOMEM;
687689

688690
dma = dma_map_page(kdev, buffer_pg, 0, RING_BUFFER_SIZE,
689691
DMA_FROM_DEVICE);
@@ -1092,6 +1094,7 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect)
10921094
return 0;
10931095

10941096
err_reclaim_tx:
1097+
netif_napi_del(&intf->tx_napi);
10951098
bcmasp_reclaim_free_all_tx(intf);
10961099
err_phy_disconnect:
10971100
if (phydev)

0 commit comments

Comments
 (0)