diff options
Diffstat (limited to 'drivers/usb/net/net1080.c')
-rw-r--r-- | drivers/usb/net/net1080.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c index 78e6a43b108..301baa72bac 100644 --- a/drivers/usb/net/net1080.c +++ b/drivers/usb/net/net1080.c | |||
@@ -20,7 +20,6 @@ | |||
20 | // #define DEBUG // error path messages, extra info | 20 | // #define DEBUG // error path messages, extra info |
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/config.h> | ||
24 | #include <linux/module.h> | 23 | #include <linux/module.h> |
25 | #include <linux/sched.h> | 24 | #include <linux/sched.h> |
26 | #include <linux/init.h> | 25 | #include <linux/init.h> |
@@ -499,25 +498,24 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
499 | static struct sk_buff * | 498 | static struct sk_buff * |
500 | net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) | 499 | net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
501 | { | 500 | { |
502 | int padlen; | ||
503 | struct sk_buff *skb2; | 501 | struct sk_buff *skb2; |
504 | struct nc_header *header = NULL; | 502 | struct nc_header *header = NULL; |
505 | struct nc_trailer *trailer = NULL; | 503 | struct nc_trailer *trailer = NULL; |
504 | int padlen = sizeof (struct nc_trailer); | ||
506 | int len = skb->len; | 505 | int len = skb->len; |
507 | 506 | ||
508 | padlen = ((len + sizeof (struct nc_header) | 507 | if (!((len + padlen + sizeof (struct nc_header)) & 0x01)) |
509 | + sizeof (struct nc_trailer)) & 0x01) ? 0 : 1; | 508 | padlen++; |
510 | if (!skb_cloned(skb)) { | 509 | if (!skb_cloned(skb)) { |
511 | int headroom = skb_headroom(skb); | 510 | int headroom = skb_headroom(skb); |
512 | int tailroom = skb_tailroom(skb); | 511 | int tailroom = skb_tailroom(skb); |
513 | 512 | ||
514 | if ((padlen + sizeof (struct nc_trailer)) <= tailroom | 513 | if (padlen <= tailroom && |
515 | && sizeof (struct nc_header) <= headroom) | 514 | sizeof(struct nc_header) <= headroom) |
516 | /* There's enough head and tail room */ | 515 | /* There's enough head and tail room */ |
517 | goto encapsulate; | 516 | goto encapsulate; |
518 | 517 | ||
519 | if ((sizeof (struct nc_header) + padlen | 518 | if ((sizeof (struct nc_header) + padlen) < |
520 | + sizeof (struct nc_trailer)) < | ||
521 | (headroom + tailroom)) { | 519 | (headroom + tailroom)) { |
522 | /* There's enough total room, so just readjust */ | 520 | /* There's enough total room, so just readjust */ |
523 | skb->data = memmove(skb->head | 521 | skb->data = memmove(skb->head |
@@ -531,7 +529,7 @@ net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) | |||
531 | /* Create a new skb to use with the correct size */ | 529 | /* Create a new skb to use with the correct size */ |
532 | skb2 = skb_copy_expand(skb, | 530 | skb2 = skb_copy_expand(skb, |
533 | sizeof (struct nc_header), | 531 | sizeof (struct nc_header), |
534 | sizeof (struct nc_trailer) + padlen, | 532 | padlen, |
535 | flags); | 533 | flags); |
536 | dev_kfree_skb_any(skb); | 534 | dev_kfree_skb_any(skb); |
537 | if (!skb2) | 535 | if (!skb2) |