Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87363d1a authored by Florian Fainelli's avatar Florian Fainelli Committed by Greg Kroah-Hartman
Browse files

net: bcmgenet: Add a check for oversized packets



[ Upstream commit 5c0862c2c962052ed5055220a00ac1cefb92fbcd ]

Occasionnaly we may get oversized packets from the hardware which
exceed the nomimal 2KiB buffer size we allocate SKBs with. Add an early
check which drops the packet to avoid invoking skb_over_panic() and move
on to processing the next packet.

Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent fe00ab1e
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -1823,6 +1823,14 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
			  __func__, p_index, ring->c_index,
			  __func__, p_index, ring->c_index,
			  ring->read_ptr, dma_length_status);
			  ring->read_ptr, dma_length_status);


		if (unlikely(len > RX_BUF_LENGTH)) {
			netif_err(priv, rx_status, dev, "oversized packet\n");
			dev->stats.rx_length_errors++;
			dev->stats.rx_errors++;
			dev_kfree_skb_any(skb);
			goto next;
		}

		if (unlikely(!(dma_flag & DMA_EOP) || !(dma_flag & DMA_SOP))) {
		if (unlikely(!(dma_flag & DMA_EOP) || !(dma_flag & DMA_SOP))) {
			netif_err(priv, rx_status, dev,
			netif_err(priv, rx_status, dev,
				  "dropping fragmented packet!\n");
				  "dropping fragmented packet!\n");