Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

epic100: hamachi: yellowfin: Fix skb allocation size

Joel Soete reported oopses during pppoe over sundance NIC, caused by
a bug in skb allocation and dma mapping code, where skb_reserve()
bytes weren't taken into account. As a followup to the patch:
"sundance: Fix oopses with corrupted skb_shared_info" very similar
code is fixed here for three other drivers.

Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Cc: Joel Soete <soete.joel@scarlet.be>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jarek Poplawski and committed by
David S. Miller
7a36df8a 78a36f25

+6 -6
+2 -2
drivers/net/epic100.c
··· 935 935 936 936 /* Fill in the Rx buffers. Handle allocation failure gracefully. */ 937 937 for (i = 0; i < RX_RING_SIZE; i++) { 938 - struct sk_buff *skb = dev_alloc_skb(ep->rx_buf_sz); 938 + struct sk_buff *skb = dev_alloc_skb(ep->rx_buf_sz + 2); 939 939 ep->rx_skbuff[i] = skb; 940 940 if (skb == NULL) 941 941 break; ··· 1233 1233 entry = ep->dirty_rx % RX_RING_SIZE; 1234 1234 if (ep->rx_skbuff[entry] == NULL) { 1235 1235 struct sk_buff *skb; 1236 - skb = ep->rx_skbuff[entry] = dev_alloc_skb(ep->rx_buf_sz); 1236 + skb = ep->rx_skbuff[entry] = dev_alloc_skb(ep->rx_buf_sz + 2); 1237 1237 if (skb == NULL) 1238 1238 break; 1239 1239 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
+2 -2
drivers/net/hamachi.c
··· 1202 1202 } 1203 1203 /* Fill in the Rx buffers. Handle allocation failure gracefully. */ 1204 1204 for (i = 0; i < RX_RING_SIZE; i++) { 1205 - struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz); 1205 + struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz + 2); 1206 1206 hmp->rx_skbuff[i] = skb; 1207 1207 if (skb == NULL) 1208 1208 break; ··· 1669 1669 entry = hmp->dirty_rx % RX_RING_SIZE; 1670 1670 desc = &(hmp->rx_ring[entry]); 1671 1671 if (hmp->rx_skbuff[entry] == NULL) { 1672 - struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz); 1672 + struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz + 2); 1673 1673 1674 1674 hmp->rx_skbuff[entry] = skb; 1675 1675 if (skb == NULL)
+2 -2
drivers/net/yellowfin.c
··· 744 744 } 745 745 746 746 for (i = 0; i < RX_RING_SIZE; i++) { 747 - struct sk_buff *skb = dev_alloc_skb(yp->rx_buf_sz); 747 + struct sk_buff *skb = dev_alloc_skb(yp->rx_buf_sz + 2); 748 748 yp->rx_skbuff[i] = skb; 749 749 if (skb == NULL) 750 750 break; ··· 1157 1157 for (; yp->cur_rx - yp->dirty_rx > 0; yp->dirty_rx++) { 1158 1158 entry = yp->dirty_rx % RX_RING_SIZE; 1159 1159 if (yp->rx_skbuff[entry] == NULL) { 1160 - struct sk_buff *skb = dev_alloc_skb(yp->rx_buf_sz); 1160 + struct sk_buff *skb = dev_alloc_skb(yp->rx_buf_sz + 2); 1161 1161 if (skb == NULL) 1162 1162 break; /* Better luck next round. */ 1163 1163 yp->rx_skbuff[entry] = skb;