Commit 59f8e169e25c5fce91826412c38359ecaf940b82
Committed by
David S. Miller
1 parent
855b0993f2
Exists in
master
and in
7 other branches
via-velocity: Fix DMA mapping length errors on transmit.
From: Dave Jones <davej@redhat.com> The dma-debug changes caught that this driver uses the wrong DMA mapping length when skb_padto() does something. With suggestions from Eric Dumazet. Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 7 additions and 8 deletions Side-by-side Diff
drivers/net/via-velocity.c
... | ... | @@ -1838,17 +1838,19 @@ |
1838 | 1838 | { |
1839 | 1839 | struct sk_buff *skb = tdinfo->skb; |
1840 | 1840 | int i; |
1841 | + int pktlen; | |
1841 | 1842 | |
1842 | 1843 | /* |
1843 | 1844 | * Don't unmap the pre-allocated tx_bufs |
1844 | 1845 | */ |
1845 | 1846 | if (tdinfo->skb_dma) { |
1846 | 1847 | |
1848 | + pktlen = (skb->len > ETH_ZLEN ? : ETH_ZLEN); | |
1847 | 1849 | for (i = 0; i < tdinfo->nskb_dma; i++) { |
1848 | 1850 | #ifdef VELOCITY_ZERO_COPY_SUPPORT |
1849 | 1851 | pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], le16_to_cpu(td->tdesc1.len), PCI_DMA_TODEVICE); |
1850 | 1852 | #else |
1851 | - pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], skb->len, PCI_DMA_TODEVICE); | |
1853 | + pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], pktlen, PCI_DMA_TODEVICE); | |
1852 | 1854 | #endif |
1853 | 1855 | tdinfo->skb_dma[i] = 0; |
1854 | 1856 | } |
1855 | 1857 | |
... | ... | @@ -2080,17 +2082,14 @@ |
2080 | 2082 | struct tx_desc *td_ptr; |
2081 | 2083 | struct velocity_td_info *tdinfo; |
2082 | 2084 | unsigned long flags; |
2083 | - int pktlen = skb->len; | |
2085 | + int pktlen; | |
2084 | 2086 | __le16 len; |
2085 | 2087 | int index; |
2086 | 2088 | |
2087 | 2089 | |
2088 | - | |
2089 | - if (skb->len < ETH_ZLEN) { | |
2090 | - if (skb_padto(skb, ETH_ZLEN)) | |
2091 | - goto out; | |
2092 | - pktlen = ETH_ZLEN; | |
2093 | - } | |
2090 | + if (skb_padto(skb, ETH_ZLEN)) | |
2091 | + goto out; | |
2092 | + pktlen = max_t(unsigned int, skb->len, ETH_ZLEN); | |
2094 | 2093 | |
2095 | 2094 | len = cpu_to_le16(pktlen); |
2096 | 2095 |