If the source port of a received frame does not map to a port with a
netdev, sparx5_fdma_rx_get_frame() returns false without consuming the
DB. The DB keeps its DONE bit, so every following poll picks the same
DB and grows its skb with skb_put() again. This ends in
skb_over_panic(), or in an RX stall if no more frames arrive.
Drop the frame and return true, so that the DB is consumed like any
other. Remove the extraction queue flush, as the FDMA has already
extracted the frame, and ratelimit the error, as the source port comes
from the hardware.
Confirmed on Sparx5 (PCB135) with a kernel modified to give received
frames an out-of-range source port, which made the board reset. The fix
was tested the same way: only the bad frames are dropped.
Fixes: 10615907e9b5 ("net: sparx5: switchdev: adding frame DMA functionality")
Reported-by: Zhang Hewei <redacted>
Closes: https://lore.kernel.org/netdev/tencent_ACC296C1F221C304053BD0F1F4B0D2C2BA06@qq.com/ (local)
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
index 15ec9b053824f..8675702bf1504 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
@@ -157,9 +157,15 @@ static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx
sparx5->ports[fi.src_port] :
NULL;
if (!port || !port->ndev) {
- dev_err(sparx5->dev, "Data on inactive port %d\n", fi.src_port);
- sparx5_xtr_flush(sparx5, XTR_QUEUE);
- return false;
+ dev_err_ratelimited(sparx5->dev, "Data on inactive port %d\n",
+ fi.src_port);
+
+ /* Drop the frame, but report the DB as consumed so the
+ * caller advances past it and recycles the DCB.
+ */
+ kfree_skb(skb);
+
+ return true;
}
skb->dev = port->ndev;
skb_pull(skb, IFH_LEN * sizeof(u32));
--
2.34.1