From: Michael Chan Date: Tue, 10 Jul 2012 10:04:40 +0000 (+0000) Subject: bnx2: Fix bug in bnx2_free_tx_skbs(). X-Git-Tag: v2.6.39-400.9.0~338^2~127 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=904ba459f9638dcc5798c74da2ddcaf4dcec58ea;p=users%2Fjedix%2Flinux-maple.git bnx2: Fix bug in bnx2_free_tx_skbs(). In rare cases, bnx2x_free_tx_skbs() can unmap the wrong DMA address when it gets to the last entry of the tx ring. We were not using the proper macro to skip the last entry when advancing the tx index. Reported-by: Zongyun Lai Reviewed-by: Jeffrey Huang (cherry picked from commit c1f5163de417dab01fa9daaf09a74bbb19303f3c) Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Joe Jin --- diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 367e8946798c..4cf9ae0ce478 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -5377,7 +5377,7 @@ bnx2_free_tx_skbs(struct bnx2 *bp) int k, last; if (skb == NULL) { - j++; + j = NEXT_TX_BD(j); continue; } @@ -5389,8 +5389,8 @@ bnx2_free_tx_skbs(struct bnx2 *bp) tx_buf->skb = NULL; last = tx_buf->nr_frags; - j++; - for (k = 0; k < last; k++, j++) { + j = NEXT_TX_BD(j); + for (k = 0; k < last; k++, j = NEXT_TX_BD(j)) { tx_buf = &txr->tx_buf_ring[TX_RING_IDX(j)]; dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(tx_buf, mapping),