Re: [PATCH net v5 2/2] net: atl1c: free the RX buffer when the descriptor reports an error

From: netdev-bot+sashiko

Date: Sun Nov 29 2026 - 06:49:04 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In atl1c_clean_rx()
(drivers/net/ethernet/atheros/atl1c/atl1c_main.c), the new RRD check…

--

net: atl1c: free the RX buffer when the descriptor reports an error

This commit changes atl1c_clean_rx() so that errored frames no longer
leak their skb and DMA mapping: the buffer is now unmapped and freed. It
also checks the RFD count and index in each RRD against
rfd_ring->next_to_clean. On a mismatch it schedules an adapter reset
through ATL1C_WORK_EVENT_RESET. Finally, it adds a dma_rmb() after the
valid-bit test and clears the RRD ring in atl1c_clean_rx_ring().

> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> index afab3e16903ba..8383203623c17 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c

[ ... ]

> @@ -1952,47 +1947,66 @@ static int atl1c_clean_rx(struct napi_struct *napi, int budget)
> if (work_done >= budget)
> break;
> rrs = ATL1C_RRD_DESC(rrd_ring, rrd_ring->next_to_clean);
> - if (likely(RRS_RXD_IS_VALID(rrs->word3))) {
> - rfd_num = (rrs->word0 >> RRS_RX_RFD_CNT_SHIFT) &
> - RRS_RX_RFD_CNT_MASK;
> - if (unlikely(rfd_num != 1))
> - /* TODO support mul rfd*/
> - if (netif_msg_rx_err(adapter))
> - dev_warn(&pdev->dev,
> - "Multi rfd not support yet!\n");
> - goto rrs_checked;
> - } else {
> + if (!RRS_RXD_IS_VALID(rrs->word3))
> + break;
> +

[ ... ]

> + rrs_word0 = le32_to_cpu(rrs->word0);
> + rfd_num = (rrs_word0 >> RRS_RX_RFD_CNT_SHIFT) &
> + RRS_RX_RFD_CNT_MASK;
> + rfd_index = (rrs_word0 >> RRS_RX_RFD_INDEX_SHIFT) &
> + RRS_RX_RFD_INDEX_MASK;
> + buffer_info = &rfd_ring->buffer_info[rfd_ring->next_to_clean];
> +

[ ... ]

> + if (unlikely(rfd_num != 1 ||
> + rfd_index != rfd_ring->next_to_clean ||
> + !buffer_info->skb)) {
> + dev_err_ratelimited(&pdev->dev,
> + "RRD out of sync: RFD count %u index %u, expected index %u%s; resetting\n",
> + rfd_num, rfd_index,
> + rfd_ring->next_to_clean,
> + buffer_info->skb ? "" : " (no buffer)");
> + set_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event);
> + schedule_work(&adapter->common_task);
> break;
> }

[Severity: Medium]
Can this check turn a legitimate multi-RFD frame into a full controller
reset?

For any mtu <= 1522, atl1c_set_rxbufsize() leaves rx_buffer_len at
AT_RX_BUF_SIZE (1522):

adapter->rx_buffer_len = mtu > AT_RX_BUF_SIZE ?
roundup(mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN, 8) : AT_RX_BUF_SIZE;

atl1c_configure_rx() writes that value to REG_RX_BUF_SIZE. Meanwhile
atl1c_configure_mac() sets the MAC frame limit to mtu + 22:

AT_WRITE_REG(hw, REG_MTU, hw->max_frame_size + ETH_HLEN +
VLAN_HLEN + ETH_FCS_LEN);

So with 1501 <= mtu <= 1522 (mtu 1508 for RFC 4638 PPPoE, for example),
the MAC accepts frames of up to 1523..1544 bytes into 1522-byte RFDs.

Suppose the device splits such a frame over two RFDs and reports
RRS_RX_RFD_CNT = 2. This branch then sets ATL1C_WORK_EVENT_RESET, and
atl1c_common_task() runs netif_device_detach(), atl1c_down() and
atl1c_up() once per frame.

Errored multi-RFD frames (RRS_RX_ERR_SUM or RRS_802_3_LEN_ERR) used to
be consumed by atl1c_clean_rrd() and atl1c_clean_rfd() with rfd_num, and
RX carried on. With this patch they also reset the controller. Nothing
limits how often the reset can be scheduled, so a peer that keeps sending
such frames could keep the link flapping.

The commit message names alx_clean_rx_irq() as the model. alx can treat
a count other than 1 as fatal because its rxbuf_size comes from
ALX_MAX_FRAME_LEN(mtu), which is always at least the ALX_MTU register
value. atl1c does not hold to that for mtu 1501..1522.

It isn't confirmed whether the hardware splits an oversized frame across
RFDs or truncates it into one. The old "TODO support mul rfd" branches
and the 4-bit RFD count field suggest that splitting can happen.

Would it work to size rx_buffer_len from the same expression as REG_MTU,
for example max(AT_RX_BUF_SIZE, roundup(mtu + ETH_HLEN + VLAN_HLEN +
ETH_FCS_LEN, 8))? Another option is to drop and recycle a multi-RFD frame
whose index matches next_to_clean, and keep the reset for a real desync.

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125113120.99743-1-federico%40rimpianto.com