Commit 9bcbcf4d authored by dave rientjes's avatar dave rientjes Committed by Greg Kroah-Hartman

USB: net1080 inherent pad length

The size of struct nc_trailer is inherently the newtailroom pad.
Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5482687b
...@@ -498,25 +498,24 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ...@@ -498,25 +498,24 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
static struct sk_buff * static struct sk_buff *
net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
{ {
int padlen;
struct sk_buff *skb2; struct sk_buff *skb2;
struct nc_header *header = NULL; struct nc_header *header = NULL;
struct nc_trailer *trailer = NULL; struct nc_trailer *trailer = NULL;
int padlen = sizeof (struct nc_trailer);
int len = skb->len; int len = skb->len;
padlen = ((len + sizeof (struct nc_header) if (!((len + padlen + sizeof (struct nc_header)) & 0x01))
+ sizeof (struct nc_trailer)) & 0x01) ? 0 : 1; padlen++;
if (!skb_cloned(skb)) { if (!skb_cloned(skb)) {
int headroom = skb_headroom(skb); int headroom = skb_headroom(skb);
int tailroom = skb_tailroom(skb); int tailroom = skb_tailroom(skb);
if ((padlen + sizeof (struct nc_trailer)) <= tailroom if (padlen <= tailroom &&
&& sizeof (struct nc_header) <= headroom) sizeof(struct nc_header) <= headroom)
/* There's enough head and tail room */ /* There's enough head and tail room */
goto encapsulate; goto encapsulate;
if ((sizeof (struct nc_header) + padlen if ((sizeof (struct nc_header) + padlen) <
+ sizeof (struct nc_trailer)) <
(headroom + tailroom)) { (headroom + tailroom)) {
/* There's enough total room, so just readjust */ /* There's enough total room, so just readjust */
skb->data = memmove(skb->head skb->data = memmove(skb->head
...@@ -530,7 +529,7 @@ net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) ...@@ -530,7 +529,7 @@ net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
/* Create a new skb to use with the correct size */ /* Create a new skb to use with the correct size */
skb2 = skb_copy_expand(skb, skb2 = skb_copy_expand(skb,
sizeof (struct nc_header), sizeof (struct nc_header),
sizeof (struct nc_trailer) + padlen, padlen,
flags); flags);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
if (!skb2) if (!skb2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment