OSDN Git Service

net: mac802154: tx: expand tailroom if necessary
authorAlexander Aring <aring@mojatatu.com>
Mon, 2 Jul 2018 20:32:03 +0000 (16:32 -0400)
committerStefan Schmidt <stefan@datenfreihafen.org>
Mon, 6 Aug 2018 09:21:37 +0000 (11:21 +0200)
This patch is necessary if case of AF_PACKET or other socket interface
which I am aware of it and didn't allocated the necessary room.

Reported-by: David Palma <david.palma@ntnu.no>
Reported-by: Rabi Narayan Sahoo <rabinarayans0828@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Alexander Aring <aring@mojatatu.com>
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
net/mac802154/tx.c

index 7e25345..bcd1a5e 100644 (file)
@@ -63,8 +63,21 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
        int ret;
 
        if (!(local->hw.flags & IEEE802154_HW_TX_OMIT_CKSUM)) {
-               u16 crc = crc_ccitt(0, skb->data, skb->len);
+               struct sk_buff *nskb;
+               u16 crc;
+
+               if (unlikely(skb_tailroom(skb) < IEEE802154_FCS_LEN)) {
+                       nskb = skb_copy_expand(skb, 0, IEEE802154_FCS_LEN,
+                                              GFP_ATOMIC);
+                       if (likely(nskb)) {
+                               consume_skb(skb);
+                               skb = nskb;
+                       } else {
+                               goto err_tx;
+                       }
+               }
 
+               crc = crc_ccitt(0, skb->data, skb->len);
                put_unaligned_le16(crc, skb_put(skb, 2));
        }