diff options
36 files changed, 74 insertions, 103 deletions
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c index 1b1cb0026072..157eda573925 100644 --- a/drivers/net/3c527.c +++ b/drivers/net/3c527.c | |||
@@ -1031,8 +1031,7 @@ static int mc32_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1031 | return 1; | 1031 | return 1; |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | skb = skb_padto(skb, ETH_ZLEN); | 1034 | if (skb_padto(skb, ETH_ZLEN)) { |
1035 | if (skb == NULL) { | ||
1036 | netif_wake_queue(dev); | 1035 | netif_wake_queue(dev); |
1037 | return 0; | 1036 | return 0; |
1038 | } | 1037 | } |
diff --git a/drivers/net/82596.c b/drivers/net/82596.c index da0c878dcba8..8a9f7d61b9b1 100644 --- a/drivers/net/82596.c +++ b/drivers/net/82596.c | |||
@@ -1070,8 +1070,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1070 | skb->len, (unsigned int)skb->data)); | 1070 | skb->len, (unsigned int)skb->data)); |
1071 | 1071 | ||
1072 | if (skb->len < ETH_ZLEN) { | 1072 | if (skb->len < ETH_ZLEN) { |
1073 | skb = skb_padto(skb, ETH_ZLEN); | 1073 | if (skb_padto(skb, ETH_ZLEN)) |
1074 | if (skb == NULL) | ||
1075 | return 0; | 1074 | return 0; |
1076 | length = ETH_ZLEN; | 1075 | length = ETH_ZLEN; |
1077 | } | 1076 | } |
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c index 79bb56b8dcef..71165ac0257a 100644 --- a/drivers/net/a2065.c +++ b/drivers/net/a2065.c | |||
@@ -573,8 +573,7 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
573 | 573 | ||
574 | if (len < ETH_ZLEN) { | 574 | if (len < ETH_ZLEN) { |
575 | len = ETH_ZLEN; | 575 | len = ETH_ZLEN; |
576 | skb = skb_padto(skb, ETH_ZLEN); | 576 | if (skb_padto(skb, ETH_ZLEN)) |
577 | if (skb == NULL) | ||
578 | return 0; | 577 | return 0; |
579 | } | 578 | } |
580 | 579 | ||
diff --git a/drivers/net/ariadne.c b/drivers/net/ariadne.c index d1b6b1f794e2..a9bb7a4aff98 100644 --- a/drivers/net/ariadne.c +++ b/drivers/net/ariadne.c | |||
@@ -607,8 +607,7 @@ static int ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
607 | /* FIXME: is the 79C960 new enough to do its own padding right ? */ | 607 | /* FIXME: is the 79C960 new enough to do its own padding right ? */ |
608 | if (skb->len < ETH_ZLEN) | 608 | if (skb->len < ETH_ZLEN) |
609 | { | 609 | { |
610 | skb = skb_padto(skb, ETH_ZLEN); | 610 | if (skb_padto(skb, ETH_ZLEN)) |
611 | if (skb == NULL) | ||
612 | return 0; | 611 | return 0; |
613 | len = ETH_ZLEN; | 612 | len = ETH_ZLEN; |
614 | } | 613 | } |
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c index 36475eb2727f..312955d07b28 100644 --- a/drivers/net/arm/ether1.c +++ b/drivers/net/arm/ether1.c | |||
@@ -700,8 +700,7 @@ ether1_sendpacket (struct sk_buff *skb, struct net_device *dev) | |||
700 | } | 700 | } |
701 | 701 | ||
702 | if (skb->len < ETH_ZLEN) { | 702 | if (skb->len < ETH_ZLEN) { |
703 | skb = skb_padto(skb, ETH_ZLEN); | 703 | if (skb_padto(skb, ETH_ZLEN)) |
704 | if (skb == NULL) | ||
705 | goto out; | 704 | goto out; |
706 | } | 705 | } |
707 | 706 | ||
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c index f1d5b1027ff7..081074180e62 100644 --- a/drivers/net/arm/ether3.c +++ b/drivers/net/arm/ether3.c | |||
@@ -518,8 +518,7 @@ ether3_sendpacket(struct sk_buff *skb, struct net_device *dev) | |||
518 | 518 | ||
519 | length = (length + 1) & ~1; | 519 | length = (length + 1) & ~1; |
520 | if (length != skb->len) { | 520 | if (length != skb->len) { |
521 | skb = skb_padto(skb, length); | 521 | if (skb_padto(skb, length)) |
522 | if (skb == NULL) | ||
523 | goto out; | 522 | goto out; |
524 | } | 523 | } |
525 | 524 | ||
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c index 442b2cbeb58a..91783a8008be 100644 --- a/drivers/net/atarilance.c +++ b/drivers/net/atarilance.c | |||
@@ -804,8 +804,7 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev ) | |||
804 | ++len; | 804 | ++len; |
805 | 805 | ||
806 | if (len > skb->len) { | 806 | if (len > skb->len) { |
807 | skb = skb_padto(skb, len); | 807 | if (skb_padto(skb, len)) |
808 | if (skb == NULL) | ||
809 | return 0; | 808 | return 0; |
810 | } | 809 | } |
811 | 810 | ||
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c index 39f36aa05aa8..565a54f1d06a 100644 --- a/drivers/net/cassini.c +++ b/drivers/net/cassini.c | |||
@@ -2915,8 +2915,7 @@ static int cas_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2915 | */ | 2915 | */ |
2916 | static int ring; | 2916 | static int ring; |
2917 | 2917 | ||
2918 | skb = skb_padto(skb, cp->min_frame_size); | 2918 | if (skb_padto(skb, cp->min_frame_size)) |
2919 | if (!skb) | ||
2920 | return 0; | 2919 | return 0; |
2921 | 2920 | ||
2922 | /* XXX: we need some higher-level QoS hooks to steer packets to | 2921 | /* XXX: we need some higher-level QoS hooks to steer packets to |
diff --git a/drivers/net/declance.c b/drivers/net/declance.c index f130bdab3fd3..d3d958e7ac56 100644 --- a/drivers/net/declance.c +++ b/drivers/net/declance.c | |||
@@ -885,8 +885,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
885 | len = skblen; | 885 | len = skblen; |
886 | 886 | ||
887 | if (len < ETH_ZLEN) { | 887 | if (len < ETH_ZLEN) { |
888 | skb = skb_padto(skb, ETH_ZLEN); | 888 | if (skb_padto(skb, ETH_ZLEN)) |
889 | if (skb == NULL) | ||
890 | return 0; | 889 | return 0; |
891 | len = ETH_ZLEN; | 890 | len = ETH_ZLEN; |
892 | } | 891 | } |
diff --git a/drivers/net/depca.c b/drivers/net/depca.c index 0941d40f046f..e946c43d3b10 100644 --- a/drivers/net/depca.c +++ b/drivers/net/depca.c | |||
@@ -938,11 +938,8 @@ static int depca_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
938 | if (skb->len < 1) | 938 | if (skb->len < 1) |
939 | goto out; | 939 | goto out; |
940 | 940 | ||
941 | if (skb->len < ETH_ZLEN) { | 941 | if (skb_padto(skb, ETH_ZLEN)) |
942 | skb = skb_padto(skb, ETH_ZLEN); | 942 | goto out; |
943 | if (skb == NULL) | ||
944 | goto out; | ||
945 | } | ||
946 | 943 | ||
947 | netif_stop_queue(dev); | 944 | netif_stop_queue(dev); |
948 | 945 | ||
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c index a806dfe54d23..e70f172699db 100644 --- a/drivers/net/eepro.c +++ b/drivers/net/eepro.c | |||
@@ -1154,8 +1154,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1154 | printk(KERN_DEBUG "%s: entering eepro_send_packet routine.\n", dev->name); | 1154 | printk(KERN_DEBUG "%s: entering eepro_send_packet routine.\n", dev->name); |
1155 | 1155 | ||
1156 | if (length < ETH_ZLEN) { | 1156 | if (length < ETH_ZLEN) { |
1157 | skb = skb_padto(skb, ETH_ZLEN); | 1157 | if (skb_padto(skb, ETH_ZLEN)) |
1158 | if (skb == NULL) | ||
1159 | return 0; | 1158 | return 0; |
1160 | length = ETH_ZLEN; | 1159 | length = ETH_ZLEN; |
1161 | } | 1160 | } |
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c index 82bd356e4f3a..a74b20715755 100644 --- a/drivers/net/eexpress.c +++ b/drivers/net/eexpress.c | |||
@@ -677,8 +677,7 @@ static int eexp_xmit(struct sk_buff *buf, struct net_device *dev) | |||
677 | #endif | 677 | #endif |
678 | 678 | ||
679 | if (buf->len < ETH_ZLEN) { | 679 | if (buf->len < ETH_ZLEN) { |
680 | buf = skb_padto(buf, ETH_ZLEN); | 680 | if (skb_padto(buf, ETH_ZLEN)) |
681 | if (buf == NULL) | ||
682 | return 0; | 681 | return 0; |
683 | length = ETH_ZLEN; | 682 | length = ETH_ZLEN; |
684 | } | 683 | } |
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c index 8d680ce600d7..724d7dc35fa3 100644 --- a/drivers/net/epic100.c +++ b/drivers/net/epic100.c | |||
@@ -1027,11 +1027,8 @@ static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1027 | u32 ctrl_word; | 1027 | u32 ctrl_word; |
1028 | unsigned long flags; | 1028 | unsigned long flags; |
1029 | 1029 | ||
1030 | if (skb->len < ETH_ZLEN) { | 1030 | if (skb_padto(skb, ETH_ZLEN)) |
1031 | skb = skb_padto(skb, ETH_ZLEN); | 1031 | return 0; |
1032 | if (skb == NULL) | ||
1033 | return 0; | ||
1034 | } | ||
1035 | 1032 | ||
1036 | /* Caution: the write order is important here, set the field with the | 1033 | /* Caution: the write order is important here, set the field with the |
1037 | "ownership" bit last. */ | 1034 | "ownership" bit last. */ |
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c index b67545be2caa..4bf76f86d8e9 100644 --- a/drivers/net/eth16i.c +++ b/drivers/net/eth16i.c | |||
@@ -1064,8 +1064,7 @@ static int eth16i_tx(struct sk_buff *skb, struct net_device *dev) | |||
1064 | unsigned long flags; | 1064 | unsigned long flags; |
1065 | 1065 | ||
1066 | if (length < ETH_ZLEN) { | 1066 | if (length < ETH_ZLEN) { |
1067 | skb = skb_padto(skb, ETH_ZLEN); | 1067 | if (skb_padto(skb, ETH_ZLEN)) |
1068 | if (skb == NULL) | ||
1069 | return 0; | 1068 | return 0; |
1070 | length = ETH_ZLEN; | 1069 | length = ETH_ZLEN; |
1071 | } | 1070 | } |
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c index 247c8ca86033..dd1dc32dc98d 100644 --- a/drivers/net/hp100.c +++ b/drivers/net/hp100.c | |||
@@ -1487,11 +1487,8 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev) | |||
1487 | if (skb->len <= 0) | 1487 | if (skb->len <= 0) |
1488 | return 0; | 1488 | return 0; |
1489 | 1489 | ||
1490 | if (skb->len < ETH_ZLEN && lp->chip == HP100_CHIPID_SHASTA) { | 1490 | if (lp->chip == HP100_CHIPID_SHASTA && skb_padto(skb, ETH_ZLEN)) |
1491 | skb = skb_padto(skb, ETH_ZLEN); | 1491 | return 0; |
1492 | if (skb == NULL) | ||
1493 | return 0; | ||
1494 | } | ||
1495 | 1492 | ||
1496 | /* Get Tx ring tail pointer */ | 1493 | /* Get Tx ring tail pointer */ |
1497 | if (lp->txrtail->next == lp->txrhead) { | 1494 | if (lp->txrtail->next == lp->txrhead) { |
diff --git a/drivers/net/lance.c b/drivers/net/lance.c index bb5ad479210b..c1c3452c90ca 100644 --- a/drivers/net/lance.c +++ b/drivers/net/lance.c | |||
@@ -968,8 +968,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
968 | /* The old LANCE chips doesn't automatically pad buffers to min. size. */ | 968 | /* The old LANCE chips doesn't automatically pad buffers to min. size. */ |
969 | if (chip_table[lp->chip_version].flags & LANCE_MUST_PAD) { | 969 | if (chip_table[lp->chip_version].flags & LANCE_MUST_PAD) { |
970 | if (skb->len < ETH_ZLEN) { | 970 | if (skb->len < ETH_ZLEN) { |
971 | skb = skb_padto(skb, ETH_ZLEN); | 971 | if (skb_padto(skb, ETH_ZLEN)) |
972 | if (skb == NULL) | ||
973 | goto out; | 972 | goto out; |
974 | lp->tx_ring[entry].length = -ETH_ZLEN; | 973 | lp->tx_ring[entry].length = -ETH_ZLEN; |
975 | } | 974 | } |
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c index 957888de3d7e..1ab09447baa5 100644 --- a/drivers/net/lasi_82596.c +++ b/drivers/net/lasi_82596.c | |||
@@ -1083,8 +1083,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1083 | skb->len, skb->data)); | 1083 | skb->len, skb->data)); |
1084 | 1084 | ||
1085 | if (length < ETH_ZLEN) { | 1085 | if (length < ETH_ZLEN) { |
1086 | skb = skb_padto(skb, ETH_ZLEN); | 1086 | if (skb_padto(skb, ETH_ZLEN)) |
1087 | if (skb == NULL) | ||
1088 | return 0; | 1087 | return 0; |
1089 | length = ETH_ZLEN; | 1088 | length = ETH_ZLEN; |
1090 | } | 1089 | } |
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c index 94d5ea1ce8bd..bf3f343ae715 100644 --- a/drivers/net/lp486e.c +++ b/drivers/net/lp486e.c | |||
@@ -877,8 +877,7 @@ static int i596_start_xmit (struct sk_buff *skb, struct net_device *dev) { | |||
877 | length = skb->len; | 877 | length = skb->len; |
878 | 878 | ||
879 | if (length < ETH_ZLEN) { | 879 | if (length < ETH_ZLEN) { |
880 | skb = skb_padto(skb, ETH_ZLEN); | 880 | if (skb_padto(skb, ETH_ZLEN)) |
881 | if (skb == NULL) | ||
882 | return 0; | 881 | return 0; |
883 | length = ETH_ZLEN; | 882 | length = ETH_ZLEN; |
884 | } | 883 | } |
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index 5a74f63618bc..b983e1e04348 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -1939,8 +1939,7 @@ again: | |||
1939 | 1939 | ||
1940 | /* pad frames to at least ETH_ZLEN bytes */ | 1940 | /* pad frames to at least ETH_ZLEN bytes */ |
1941 | if (unlikely(skb->len < ETH_ZLEN)) { | 1941 | if (unlikely(skb->len < ETH_ZLEN)) { |
1942 | skb = skb_padto(skb, ETH_ZLEN); | 1942 | if (skb_padto(skb, ETH_ZLEN)) { |
1943 | if (skb == NULL) { | ||
1944 | /* The packet is gone, so we must | 1943 | /* The packet is gone, so we must |
1945 | * return 0 */ | 1944 | * return 0 */ |
1946 | mgp->stats.tx_dropped += 1; | 1945 | mgp->stats.tx_dropped += 1; |
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 09b11761cdfa..ea93b8f18605 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c | |||
@@ -831,8 +831,7 @@ static int fjn_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
831 | 831 | ||
832 | if (length < ETH_ZLEN) | 832 | if (length < ETH_ZLEN) |
833 | { | 833 | { |
834 | skb = skb_padto(skb, ETH_ZLEN); | 834 | if (skb_padto(skb, ETH_ZLEN)) |
835 | if (skb == NULL) | ||
836 | return 0; | 835 | return 0; |
837 | length = ETH_ZLEN; | 836 | length = ETH_ZLEN; |
838 | } | 837 | } |
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index e80d1e3aec68..9bae77ce1314 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -1374,8 +1374,7 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1374 | */ | 1374 | */ |
1375 | if (pktlen < ETH_ZLEN) | 1375 | if (pktlen < ETH_ZLEN) |
1376 | { | 1376 | { |
1377 | skb = skb_padto(skb, ETH_ZLEN); | 1377 | if (skb_padto(skb, ETH_ZLEN)) |
1378 | if (skb == NULL) | ||
1379 | return 0; | 1378 | return 0; |
1380 | pktlen = ETH_ZLEN; | 1379 | pktlen = ETH_ZLEN; |
1381 | } | 1380 | } |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 9945cc6b8d90..985afe0e6273 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -2222,8 +2222,7 @@ static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2222 | len = skb->len; | 2222 | len = skb->len; |
2223 | 2223 | ||
2224 | if (unlikely(len < ETH_ZLEN)) { | 2224 | if (unlikely(len < ETH_ZLEN)) { |
2225 | skb = skb_padto(skb, ETH_ZLEN); | 2225 | if (skb_padto(skb, ETH_ZLEN)) |
2226 | if (!skb) | ||
2227 | goto err_update_stats; | 2226 | goto err_update_stats; |
2228 | len = ETH_ZLEN; | 2227 | len = ETH_ZLEN; |
2229 | } | 2228 | } |
diff --git a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c index bcef03feb2fc..efd0f235020f 100644 --- a/drivers/net/seeq8005.c +++ b/drivers/net/seeq8005.c | |||
@@ -396,8 +396,7 @@ static int seeq8005_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
396 | unsigned char *buf; | 396 | unsigned char *buf; |
397 | 397 | ||
398 | if (length < ETH_ZLEN) { | 398 | if (length < ETH_ZLEN) { |
399 | skb = skb_padto(skb, ETH_ZLEN); | 399 | if (skb_padto(skb, ETH_ZLEN)) |
400 | if (skb == NULL) | ||
401 | return 0; | 400 | return 0; |
402 | length = ETH_ZLEN; | 401 | length = ETH_ZLEN; |
403 | } | 402 | } |
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c index 31dd3f036fa8..df39f3447655 100644 --- a/drivers/net/sis190.c +++ b/drivers/net/sis190.c | |||
@@ -1156,8 +1156,7 @@ static int sis190_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1156 | dma_addr_t mapping; | 1156 | dma_addr_t mapping; |
1157 | 1157 | ||
1158 | if (unlikely(skb->len < ETH_ZLEN)) { | 1158 | if (unlikely(skb->len < ETH_ZLEN)) { |
1159 | skb = skb_padto(skb, ETH_ZLEN); | 1159 | if (skb_padto(skb, ETH_ZLEN)) { |
1160 | if (!skb) { | ||
1161 | tp->stats.tx_dropped++; | 1160 | tp->stats.tx_dropped++; |
1162 | goto out; | 1161 | goto out; |
1163 | } | 1162 | } |
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c index 38a26df4095f..f3efbd177ae7 100644 --- a/drivers/net/sk98lin/skge.c +++ b/drivers/net/sk98lin/skge.c | |||
@@ -1525,7 +1525,7 @@ struct sk_buff *pMessage) /* pointer to send-message */ | |||
1525 | ** This is to resolve faulty padding by the HW with 0xaa bytes. | 1525 | ** This is to resolve faulty padding by the HW with 0xaa bytes. |
1526 | */ | 1526 | */ |
1527 | if (BytesSend < C_LEN_ETHERNET_MINSIZE) { | 1527 | if (BytesSend < C_LEN_ETHERNET_MINSIZE) { |
1528 | if ((pMessage = skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) == NULL) { | 1528 | if (skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) { |
1529 | spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags); | 1529 | spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags); |
1530 | return 0; | 1530 | return 0; |
1531 | } | 1531 | } |
diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 536dd1cf7f79..19a4a16055dc 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c | |||
@@ -2310,8 +2310,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev) | |||
2310 | u64 map; | 2310 | u64 map; |
2311 | unsigned long flags; | 2311 | unsigned long flags; |
2312 | 2312 | ||
2313 | skb = skb_padto(skb, ETH_ZLEN); | 2313 | if (skb_padto(skb, ETH_ZLEN)) |
2314 | if (!skb) | ||
2315 | return NETDEV_TX_OK; | 2314 | return NETDEV_TX_OK; |
2316 | 2315 | ||
2317 | if (!spin_trylock_irqsave(&skge->tx_lock, flags)) | 2316 | if (!spin_trylock_irqsave(&skge->tx_lock, flags)) |
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c index 6cf16f322ad5..8b0321f1976c 100644 --- a/drivers/net/smc9194.c +++ b/drivers/net/smc9194.c | |||
@@ -523,8 +523,7 @@ static int smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * de | |||
523 | length = skb->len; | 523 | length = skb->len; |
524 | 524 | ||
525 | if (length < ETH_ZLEN) { | 525 | if (length < ETH_ZLEN) { |
526 | skb = skb_padto(skb, ETH_ZLEN); | 526 | if (skb_padto(skb, ETH_ZLEN)) { |
527 | if (skb == NULL) { | ||
528 | netif_wake_queue(dev); | 527 | netif_wake_queue(dev); |
529 | return 0; | 528 | return 0; |
530 | } | 529 | } |
diff --git a/drivers/net/sonic.c b/drivers/net/sonic.c index 90b818a8de6e..cab0dd958492 100644 --- a/drivers/net/sonic.c +++ b/drivers/net/sonic.c | |||
@@ -231,8 +231,7 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
231 | 231 | ||
232 | length = skb->len; | 232 | length = skb->len; |
233 | if (length < ETH_ZLEN) { | 233 | if (length < ETH_ZLEN) { |
234 | skb = skb_padto(skb, ETH_ZLEN); | 234 | if (skb_padto(skb, ETH_ZLEN)) |
235 | if (skb == NULL) | ||
236 | return 0; | 235 | return 0; |
237 | length = ETH_ZLEN; | 236 | length = ETH_ZLEN; |
238 | } | 237 | } |
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c index 9b7805be21da..c158eedc7813 100644 --- a/drivers/net/starfire.c +++ b/drivers/net/starfire.c | |||
@@ -1349,8 +1349,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1349 | 1349 | ||
1350 | #if defined(ZEROCOPY) && defined(HAS_BROKEN_FIRMWARE) | 1350 | #if defined(ZEROCOPY) && defined(HAS_BROKEN_FIRMWARE) |
1351 | if (skb->ip_summed == CHECKSUM_HW) { | 1351 | if (skb->ip_summed == CHECKSUM_HW) { |
1352 | skb = skb_padto(skb, (skb->len + PADDING_MASK) & ~PADDING_MASK); | 1352 | if (skb_padto(skb, (skb->len + PADDING_MASK) & ~PADDING_MASK)) |
1353 | if (skb == NULL) | ||
1354 | return NETDEV_TX_OK; | 1353 | return NETDEV_TX_OK; |
1355 | } | 1354 | } |
1356 | #endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */ | 1355 | #endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */ |
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c index fdc21037f6dc..c80a4f1d5f7a 100644 --- a/drivers/net/via-rhine.c +++ b/drivers/net/via-rhine.c | |||
@@ -1284,11 +1284,8 @@ static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1284 | /* Calculate the next Tx descriptor entry. */ | 1284 | /* Calculate the next Tx descriptor entry. */ |
1285 | entry = rp->cur_tx % TX_RING_SIZE; | 1285 | entry = rp->cur_tx % TX_RING_SIZE; |
1286 | 1286 | ||
1287 | if (skb->len < ETH_ZLEN) { | 1287 | if (skb_padto(skb, ETH_ZLEN)) |
1288 | skb = skb_padto(skb, ETH_ZLEN); | 1288 | return 0; |
1289 | if (skb == NULL) | ||
1290 | return 0; | ||
1291 | } | ||
1292 | 1289 | ||
1293 | rp->tx_skbuff[entry] = skb; | 1290 | rp->tx_skbuff[entry] = skb; |
1294 | 1291 | ||
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 879eb427607c..a915fe6c6aa5 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c | |||
@@ -924,8 +924,7 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
924 | 924 | ||
925 | if (length < ETH_ZLEN) | 925 | if (length < ETH_ZLEN) |
926 | { | 926 | { |
927 | skb = skb_padto(skb, ETH_ZLEN); | 927 | if (skb_padto(skb, ETH_ZLEN)) |
928 | if (skb == NULL) | ||
929 | return 0; | 928 | return 0; |
930 | length = ETH_ZLEN; | 929 | length = ETH_ZLEN; |
931 | } | 930 | } |
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index f7724eb2fa7e..561250f73fd3 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c | |||
@@ -3194,11 +3194,8 @@ wavelan_packet_xmit(struct sk_buff * skb, | |||
3194 | * and we don't have the Ethernet specific requirement of beeing | 3194 | * and we don't have the Ethernet specific requirement of beeing |
3195 | * able to detect collisions, therefore in theory we don't really | 3195 | * able to detect collisions, therefore in theory we don't really |
3196 | * need to pad. Jean II */ | 3196 | * need to pad. Jean II */ |
3197 | if (skb->len < ETH_ZLEN) { | 3197 | if (skb_padto(skb, ETH_ZLEN)) |
3198 | skb = skb_padto(skb, ETH_ZLEN); | 3198 | return 0; |
3199 | if (skb == NULL) | ||
3200 | return 0; | ||
3201 | } | ||
3202 | 3199 | ||
3203 | wv_packet_write(dev, skb->data, skb->len); | 3200 | wv_packet_write(dev, skb->data, skb->len); |
3204 | 3201 | ||
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c index fd0f43b7db5b..ecec8e5db786 100644 --- a/drivers/net/yellowfin.c +++ b/drivers/net/yellowfin.c | |||
@@ -862,13 +862,11 @@ static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
862 | /* Fix GX chipset errata. */ | 862 | /* Fix GX chipset errata. */ |
863 | if (cacheline_end > 24 || cacheline_end == 0) { | 863 | if (cacheline_end > 24 || cacheline_end == 0) { |
864 | len = skb->len + 32 - cacheline_end + 1; | 864 | len = skb->len + 32 - cacheline_end + 1; |
865 | if (len != skb->len) | 865 | if (skb_padto(skb, len)) { |
866 | skb = skb_padto(skb, len); | 866 | yp->tx_skbuff[entry] = NULL; |
867 | } | 867 | netif_wake_queue(dev); |
868 | if (skb == NULL) { | 868 | return 0; |
869 | yp->tx_skbuff[entry] = NULL; | 869 | } |
870 | netif_wake_queue(dev); | ||
871 | return 0; | ||
872 | } | 870 | } |
873 | } | 871 | } |
874 | yp->tx_skbuff[entry] = skb; | 872 | yp->tx_skbuff[entry] = skb; |
diff --git a/drivers/net/znet.c b/drivers/net/znet.c index 3ac047bc727d..a7c089df66e6 100644 --- a/drivers/net/znet.c +++ b/drivers/net/znet.c | |||
@@ -544,8 +544,7 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
544 | printk(KERN_DEBUG "%s: ZNet_send_packet.\n", dev->name); | 544 | printk(KERN_DEBUG "%s: ZNet_send_packet.\n", dev->name); |
545 | 545 | ||
546 | if (length < ETH_ZLEN) { | 546 | if (length < ETH_ZLEN) { |
547 | skb = skb_padto(skb, ETH_ZLEN); | 547 | if (skb_padto(skb, ETH_ZLEN)) |
548 | if (skb == NULL) | ||
549 | return 0; | 548 | return 0; |
550 | length = ETH_ZLEN; | 549 | length = ETH_ZLEN; |
551 | } | 550 | } |
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 66f8819f9568..f8c7eb79a27f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -345,7 +345,7 @@ extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, | |||
345 | extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb, | 345 | extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb, |
346 | int newheadroom, int newtailroom, | 346 | int newheadroom, int newtailroom, |
347 | gfp_t priority); | 347 | gfp_t priority); |
348 | extern struct sk_buff * skb_pad(struct sk_buff *skb, int pad); | 348 | extern int skb_pad(struct sk_buff *skb, int pad); |
349 | #define dev_kfree_skb(a) kfree_skb(a) | 349 | #define dev_kfree_skb(a) kfree_skb(a) |
350 | extern void skb_over_panic(struct sk_buff *skb, int len, | 350 | extern void skb_over_panic(struct sk_buff *skb, int len, |
351 | void *here); | 351 | void *here); |
@@ -1122,16 +1122,15 @@ static inline int skb_cow(struct sk_buff *skb, unsigned int headroom) | |||
1122 | * | 1122 | * |
1123 | * Pads up a buffer to ensure the trailing bytes exist and are | 1123 | * Pads up a buffer to ensure the trailing bytes exist and are |
1124 | * blanked. If the buffer already contains sufficient data it | 1124 | * blanked. If the buffer already contains sufficient data it |
1125 | * is untouched. Returns the buffer, which may be a replacement | 1125 | * is untouched. Otherwise it is extended. Returns zero on |
1126 | * for the original, or NULL for out of memory - in which case | 1126 | * success. The skb is freed on error. |
1127 | * the original buffer is still freed. | ||
1128 | */ | 1127 | */ |
1129 | 1128 | ||
1130 | static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len) | 1129 | static inline int skb_padto(struct sk_buff *skb, unsigned int len) |
1131 | { | 1130 | { |
1132 | unsigned int size = skb->len; | 1131 | unsigned int size = skb->len; |
1133 | if (likely(size >= len)) | 1132 | if (likely(size >= len)) |
1134 | return skb; | 1133 | return 0; |
1135 | return skb_pad(skb, len-size); | 1134 | return skb_pad(skb, len-size); |
1136 | } | 1135 | } |
1137 | 1136 | ||
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index bb7210f4005e..fe63d4efbd4d 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -781,24 +781,40 @@ struct sk_buff *skb_copy_expand(const struct sk_buff *skb, | |||
781 | * filled. Used by network drivers which may DMA or transfer data | 781 | * filled. Used by network drivers which may DMA or transfer data |
782 | * beyond the buffer end onto the wire. | 782 | * beyond the buffer end onto the wire. |
783 | * | 783 | * |
784 | * May return NULL in out of memory cases. | 784 | * May return error in out of memory cases. The skb is freed on error. |
785 | */ | 785 | */ |
786 | 786 | ||
787 | struct sk_buff *skb_pad(struct sk_buff *skb, int pad) | 787 | int skb_pad(struct sk_buff *skb, int pad) |
788 | { | 788 | { |
789 | struct sk_buff *nskb; | 789 | int err; |
790 | int ntail; | ||
790 | 791 | ||
791 | /* If the skbuff is non linear tailroom is always zero.. */ | 792 | /* If the skbuff is non linear tailroom is always zero.. */ |
792 | if (skb_tailroom(skb) >= pad) { | 793 | if (!skb_cloned(skb) && skb_tailroom(skb) >= pad) { |
793 | memset(skb->data+skb->len, 0, pad); | 794 | memset(skb->data+skb->len, 0, pad); |
794 | return skb; | 795 | return 0; |
795 | } | 796 | } |
796 | 797 | ||
797 | nskb = skb_copy_expand(skb, skb_headroom(skb), skb_tailroom(skb) + pad, GFP_ATOMIC); | 798 | ntail = skb->data_len + pad - (skb->end - skb->tail); |
799 | if (likely(skb_cloned(skb) || ntail > 0)) { | ||
800 | err = pskb_expand_head(skb, 0, ntail, GFP_ATOMIC); | ||
801 | if (unlikely(err)) | ||
802 | goto free_skb; | ||
803 | } | ||
804 | |||
805 | /* FIXME: The use of this function with non-linear skb's really needs | ||
806 | * to be audited. | ||
807 | */ | ||
808 | err = skb_linearize(skb); | ||
809 | if (unlikely(err)) | ||
810 | goto free_skb; | ||
811 | |||
812 | memset(skb->data + skb->len, 0, pad); | ||
813 | return 0; | ||
814 | |||
815 | free_skb: | ||
798 | kfree_skb(skb); | 816 | kfree_skb(skb); |
799 | if (nskb) | 817 | return err; |
800 | memset(nskb->data+nskb->len, 0, pad); | ||
801 | return nskb; | ||
802 | } | 818 | } |
803 | 819 | ||
804 | /* Trims skb to length len. It can change skb pointers. | 820 | /* Trims skb to length len. It can change skb pointers. |