030-2-smsc75xx-use-skb_cow_head-to-deal-with-cloned-skbs.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From b7c6d2675899cfff0180412c63fc9cbd5bacdb4d Mon Sep 17 00:00:00 2001
  2. From: Eric Dumazet <edumazet@google.com>
  3. Date: Wed, 19 Apr 2017 09:59:21 -0700
  4. Subject: [PATCH] smsc75xx: use skb_cow_head() to deal with cloned skbs
  5. We need to ensure there is enough headroom to push extra header,
  6. but we also need to check if we are allowed to change headers.
  7. skb_cow_head() is the proper helper to deal with this.
  8. Fixes: d0cad871703b ("smsc75xx: SMSC LAN75xx USB gigabit ethernet adapter driver")
  9. Signed-off-by: Eric Dumazet <edumazet@google.com>
  10. Cc: James Hughes <james.hughes@raspberrypi.org>
  11. Signed-off-by: David S. Miller <davem@davemloft.net>
  12. ---
  13. drivers/net/usb/smsc75xx.c | 8 ++------
  14. 1 file changed, 2 insertions(+), 6 deletions(-)
  15. --- a/drivers/net/usb/smsc75xx.c
  16. +++ b/drivers/net/usb/smsc75xx.c
  17. @@ -2193,13 +2193,9 @@ static struct sk_buff *smsc75xx_tx_fixup
  18. {
  19. u32 tx_cmd_a, tx_cmd_b;
  20. - if (skb_headroom(skb) < SMSC75XX_TX_OVERHEAD) {
  21. - struct sk_buff *skb2 =
  22. - skb_copy_expand(skb, SMSC75XX_TX_OVERHEAD, 0, flags);
  23. + if (skb_cow_head(skb, SMSC75XX_TX_OVERHEAD)) {
  24. dev_kfree_skb_any(skb);
  25. - skb = skb2;
  26. - if (!skb)
  27. - return NULL;
  28. + return NULL;
  29. }
  30. tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS;