[PATCH] usb: gadget: fix eem_wrap cloned skb logic

From: Nathan Sullivan
Date: Mon Jul 07 2014 - 11:15:56 EST


Even if the skb is cloned, we still need a ZLP or USB will stall.

Signed-off-by: Nathan Sullivan <nathan.sullivan@xxxxxx>
Acked-by: Brad Mouring <brad.mouring@xxxxxx>
---
drivers/usb/gadget/f_eem.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index d61c11d..4d8b236 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -355,20 +355,18 @@ static struct sk_buff *eem_wrap(struct gether *port, struct sk_buff *skb)
int padlen = 0;
u16 len = skb->len;

- if (!skb_cloned(skb)) {
- int headroom = skb_headroom(skb);
- int tailroom = skb_tailroom(skb);
+ int headroom = skb_headroom(skb);
+ int tailroom = skb_tailroom(skb);

- /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0,
- * stick two bytes of zero-length EEM packet on the end.
- */
- if (((len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) == 0)
- padlen += 2;
+ /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0,
+ * stick two bytes of zero-length EEM packet on the end.
+ */
+ if (((len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) == 0)
+ padlen += 2;

- if ((tailroom >= (ETH_FCS_LEN + padlen)) &&
- (headroom >= EEM_HLEN))
- goto done;
- }
+ if ((tailroom >= (ETH_FCS_LEN + padlen)) &&
+ (headroom >= EEM_HLEN) && !skb_cloned(skb))
+ goto done;

skb2 = skb_copy_expand(skb, EEM_HLEN, ETH_FCS_LEN + padlen, GFP_ATOMIC);
dev_kfree_skb_any(skb);
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/