diff options
author | dave rientjes <rientjes@google.com> | 2006-07-19 02:23:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-27 14:58:54 -0400 |
commit | 9bcbcf4d00cd2400e655a738e77f0d21b69c6771 (patch) | |
tree | 2ef039b8fd9967c9de2ef06cee17b6b8e7e00e80 /drivers/usb/net/net1080.c | |
parent | 5482687b8be4dedb8a5879f07c734ff11a88a7d5 (diff) |
USB: net1080 inherent pad length
The size of struct nc_trailer is inherently the newtailroom pad.
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/net/net1080.c')
-rw-r--r-- | drivers/usb/net/net1080.c | 15 |
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) | |||
498 | static struct sk_buff * | 498 | static struct sk_buff * |
499 | 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) |
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) |