ramips: fix cd-poll sd card remove randomly
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-4.4 / 030-1-smsc95xx-Use-skb_cow_head-to-deal-with-cloned-skbs.patch
1 From e9156cd26a495a18706e796f02a81fee41ec14f4 Mon Sep 17 00:00:00 2001
2 From: James Hughes <james.hughes@raspberrypi.org>
3 Date: Wed, 19 Apr 2017 11:13:40 +0100
4 Subject: [PATCH] smsc95xx: Use skb_cow_head to deal with cloned skbs
5
6 The driver was failing to check that the SKB wasn't cloned
7 before adding checksum data.
8 Replace existing handling to extend/copy the header buffer
9 with skb_cow_head.
10
11 Signed-off-by: James Hughes <james.hughes@raspberrypi.org>
12 Acked-by: Eric Dumazet <edumazet@google.com>
13 Acked-by: Woojung Huh <Woojung.Huh@microchip.com>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 ---
16 drivers/net/usb/smsc95xx.c | 12 ++++++------
17 1 file changed, 6 insertions(+), 6 deletions(-)
18
19 --- a/drivers/net/usb/smsc95xx.c
20 +++ b/drivers/net/usb/smsc95xx.c
21 @@ -1835,13 +1835,13 @@ static struct sk_buff *smsc95xx_tx_fixup
22 /* We do not advertise SG, so skbs should be already linearized */
23 BUG_ON(skb_shinfo(skb)->nr_frags);
24
25 - if (skb_headroom(skb) < overhead) {
26 - struct sk_buff *skb2 = skb_copy_expand(skb,
27 - overhead, 0, flags);
28 + /* Make writable and expand header space by overhead if required */
29 + if (skb_cow_head(skb, overhead)) {
30 + /* Must deallocate here as returning NULL to indicate error
31 + * means the skb won't be deallocated in the caller.
32 + */
33 dev_kfree_skb_any(skb);
34 - skb = skb2;
35 - if (!skb)
36 - return NULL;
37 + return NULL;
38 }
39
40 if (csum) {