aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/net')
-rw-r--r--drivers/usb/net/net1080.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index a9b6eeac3e3f..301baa72bac7 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -498,25 +498,24 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
498static struct sk_buff * 498static struct sk_buff *
499net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) 499net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
500{ 500{
501 int padlen;
502 struct sk_buff *skb2; 501 struct sk_buff *skb2;
503 struct nc_header *header = NULL; 502 struct nc_header *header = NULL;
504 struct nc_trailer *trailer = NULL; 503 struct nc_trailer *trailer = NULL;
504 int padlen = sizeof (struct nc_trailer);
505 int len = skb->len; 505 int len = skb->len;
506 506
507 padlen = ((len + sizeof (struct nc_header) 507 if (!((len + padlen + sizeof (struct nc_header)) & 0x01))
508 + sizeof (struct nc_trailer)) & 0x01) ? 0 : 1; 508 padlen++;
509 if (!skb_cloned(skb)) { 509 if (!skb_cloned(skb)) {
510 int headroom = skb_headroom(skb); 510 int headroom = skb_headroom(skb);
511 int tailroom = skb_tailroom(skb); 511 int tailroom = skb_tailroom(skb);
512 512
513 if ((padlen + sizeof (struct nc_trailer)) <= tailroom 513 if (padlen <= tailroom &&
514 && sizeof (struct nc_header) <= headroom) 514 sizeof(struct nc_header) <= headroom)
515 /* There's enough head and tail room */ 515 /* There's enough head and tail room */
516 goto encapsulate; 516 goto encapsulate;
517 517
518 if ((sizeof (struct nc_header) + padlen 518 if ((sizeof (struct nc_header) + padlen) <
519 + sizeof (struct nc_trailer)) <
520 (headroom + tailroom)) { 519 (headroom + tailroom)) {
521 /* There's enough total room, so just readjust */ 520 /* There's enough total room, so just readjust */
522 skb->data = memmove(skb->head 521 skb->data = memmove(skb->head
@@ -530,7 +529,7 @@ net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
530 /* Create a new skb to use with the correct size */ 529 /* Create a new skb to use with the correct size */
531 skb2 = skb_copy_expand(skb, 530 skb2 = skb_copy_expand(skb,
532 sizeof (struct nc_header), 531 sizeof (struct nc_header),
533 sizeof (struct nc_trailer) + padlen, 532 padlen,
534 flags); 533 flags);
535 dev_kfree_skb_any(skb); 534 dev_kfree_skb_any(skb);
536 if (!skb2) 535 if (!skb2)