kernel: bgmac: add more DMA related fixes
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-3.18 / 077-08-bgmac-add-check-for-oversized-packets.patch
1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Sun, 12 Apr 2015 22:28:20 +0200
3 Subject: [PATCH] bgmac: add check for oversized packets
4
5 In very rare cases, the MAC can catch an internal buffer that is bigger
6 than it's supposed to be. Instead of crashing the kernel, simply pass
7 the buffer back to the hardware
8
9 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 ---
11
12 --- a/drivers/net/ethernet/broadcom/bgmac.c
13 +++ b/drivers/net/ethernet/broadcom/bgmac.c
14 @@ -422,6 +422,14 @@ static int bgmac_dma_rx_read(struct bgma
15 break;
16 }
17
18 + if (len > BGMAC_RX_ALLOC_SIZE) {
19 + bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
20 + ring->start);
21 + rx->len = cpu_to_le16(0xdead);
22 + rx->flags = cpu_to_le16(0xbeef);
23 + break;
24 + }
25 +
26 /* Omit CRC. */
27 len -= ETH_FCS_LEN;
28