Re: [PATCH net 1/2] net: bcm4908_enet: keep the RX buffer when the refill fails

From: Florian Fainelli

Date: Wed Dec 02 2026 - 23:37:05 EST




On 12/2/2026 1:56 AM, Kordian Chmielewski wrote:
poll_rx() refills a descriptor before it passes the old buffer up the
stack, but bcm4908_enet_dma_alloc_rx_buf() writes the results of the
allocation and of the mapping into the ring slot before it checks them.
When either fails, the slot is left with buf == NULL, the old buffer is
lost while still mapped, and read_idx stays on a descriptor the DMA has
already completed. A later poll takes that descriptor again and, once
its refill works, hands the NULL buffer to build_skb(), or to
skb_free_frag() on the bad-frame path.

Allocate and map into local variables and update the slot only once
both have worked. When either fails, drop the frame and give its buffer
back to the DMA, so that the ring keeps going.

Sashiko's reviews of the TX ring series pointed this out. I have not
seen a refill fail on its own on the hardware.

Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Signed-off-by: Kordian Chmielewski <kudzo51@xxxxxxxxx>

Reviewed-by: Florian Fainelli <florian.fainelli@xxxxxxxxxxxx>
--
Florian