2
0

030-1-smsc95xx-Use-skb_cow_head-to-deal-with-cloned-skbs.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. The driver was failing to check that the SKB wasn't cloned
  6. before adding checksum data.
  7. Replace existing handling to extend/copy the header buffer
  8. with skb_cow_head.
  9. Signed-off-by: James Hughes <james.hughes@raspberrypi.org>
  10. Acked-by: Eric Dumazet <edumazet@google.com>
  11. Acked-by: Woojung Huh <Woojung.Huh@microchip.com>
  12. Signed-off-by: David S. Miller <davem@davemloft.net>
  13. ---
  14. drivers/net/usb/smsc95xx.c | 12 ++++++------
  15. 1 file changed, 6 insertions(+), 6 deletions(-)
  16. --- a/drivers/net/usb/smsc95xx.c
  17. +++ b/drivers/net/usb/smsc95xx.c
  18. @@ -1835,13 +1835,13 @@ static struct sk_buff *smsc95xx_tx_fixup
  19. /* We do not advertise SG, so skbs should be already linearized */
  20. BUG_ON(skb_shinfo(skb)->nr_frags);
  21. - if (skb_headroom(skb) < overhead) {
  22. - struct sk_buff *skb2 = skb_copy_expand(skb,
  23. - overhead, 0, flags);
  24. + /* Make writable and expand header space by overhead if required */
  25. + if (skb_cow_head(skb, overhead)) {
  26. + /* Must deallocate here as returning NULL to indicate error
  27. + * means the skb won't be deallocated in the caller.
  28. + */
  29. dev_kfree_skb_any(skb);
  30. - skb = skb2;
  31. - if (!skb)
  32. - return NULL;
  33. + return NULL;
  34. }
  35. if (csum) {