Skip to content

Commit

Permalink
stmmac: fix oversized frame reception
Browse files Browse the repository at this point in the history
The receive skb buffers can be preallocated when the link is opened
according to mtu size.
While testing on a network environment with not standard MTU (e.g. 3000),
a panic occurred if an incoming packet had a length greater than rx skb
buffer size. This is because the HW is programmed to copy, from the DMA,
an Jumbo frame and the Sw must check if the allocated buffer is enough to
store the frame.

Signed-off-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Giuseppe CAVALLARO authored and David S. Miller committed Nov 30, 2015
1 parent ae26c1c commit e527c4a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,12 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit)

frame_len = priv->hw->desc->get_rx_frame_len(p, coe);

/* check if frame_len fits the preallocated memory */
if (frame_len > priv->dma_buf_sz) {
priv->dev->stats.rx_length_errors++;
break;
}

/* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3
* Type frames (LLC/LLC-SNAP)
*/
Expand Down

0 comments on commit e527c4a

Please sign in to comment.