Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 490cb412007d ("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>

authored by

Florian Fainelli and committed by
Paolo Abeni
e5b2e810 d74b23d0

+3
+3
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
··· 684 684 685 685 intf->rx_buf_order = get_order(RING_BUFFER_SIZE); 686 686 buffer_pg = alloc_pages(GFP_KERNEL, intf->rx_buf_order); 687 + if (!buffer_pg) 688 + return -ENOMEM; 687 689 688 690 dma = dma_map_page(kdev, buffer_pg, 0, RING_BUFFER_SIZE, 689 691 DMA_FROM_DEVICE); ··· 1094 1092 return 0; 1095 1093 1096 1094 err_reclaim_tx: 1095 + netif_napi_del(&intf->tx_napi); 1097 1096 bcmasp_reclaim_free_all_tx(intf); 1098 1097 err_phy_disconnect: 1099 1098 if (phydev)