summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
diff options
context:
space:
mode:
authorGiuseppe CAVALLARO2015-11-26 08:35:45 +0100
committerDavid S. Miller2015-11-30 20:52:52 +0100
commite527c4a769d375ac0472450c52bde29087f49cd9 (patch)
tree3418a8c1016d017de9260e0c544a5b19d9a53568 /drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
parentstmmac: fix PHY reset during resume (diff)
downloadkernel-qcow2-linux-e527c4a769d375ac0472450c52bde29087f49cd9.tar.gz
kernel-qcow2-linux-e527c4a769d375ac0472450c52bde29087f49cd9.tar.xz
kernel-qcow2-linux-e527c4a769d375ac0472450c52bde29087f49cd9.zip
stmmac: fix oversized frame reception
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>
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac/stmmac_main.c')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 6256b32cec37..3c6549aee11d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -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)
*/