kernel: bgmac: use upstream accepted patches
[oweals/openwrt.git] / target / linux / generic / patches-4.4 / 076-0003-net-bgmac-Fix-infinite-loop-in-bgmac_dma_tx_add.patch
1 From e86663c475d384ab5f46cb5637e9b7ad08c5c505 Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Fri, 15 Jul 2016 15:42:52 -0700
4 Subject: [PATCH] net: bgmac: Fix infinite loop in bgmac_dma_tx_add()
5
6 Nothing is decrementing the index "i" while we are cleaning up the
7 fragments we could not successful transmit.
8
9 Fixes: 9cde94506eacf ("bgmac: implement scatter/gather support")
10 Reported-by: coverity (CID 1352048)
11 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14  drivers/net/ethernet/broadcom/bgmac.c | 2 +-
15  1 file changed, 1 insertion(+), 1 deletion(-)
16
17 --- a/drivers/net/ethernet/broadcom/bgmac.c
18 +++ b/drivers/net/ethernet/broadcom/bgmac.c
19 @@ -207,7 +207,7 @@ err_dma:
20         dma_unmap_single(dma_dev, slot->dma_addr, skb_headlen(skb),
21                          DMA_TO_DEVICE);
22  
23 -       while (i > 0) {
24 +       while (i-- > 0) {
25                 int index = (ring->end + i) % BGMAC_TX_RING_SLOTS;
26                 struct bgmac_slot_info *slot = &ring->slots[index];
27                 u32 ctl1 = le32_to_cpu(ring->cpu_base[index].ctl1);