From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Aring Subject: [PATCH wpan 2/2] net: mac802154: tx: expand tailroom if necessary Date: Mon, 2 Jul 2018 16:32:03 -0400 Message-ID: <20180702203203.21316-2-aring@mojatatu.com> References: <20180702203203.21316-1-aring@mojatatu.com> Cc: linux-wpan@vger.kernel.org, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring To: stefan@osg.samsung.com Return-path: Received: from mail-it0-f65.google.com ([209.85.214.65]:37750 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752580AbeGBUcS (ORCPT ); Mon, 2 Jul 2018 16:32:18 -0400 Received: by mail-it0-f65.google.com with SMTP id p17-v6so114166itc.2 for ; Mon, 02 Jul 2018 13:32:17 -0700 (PDT) In-Reply-To: <20180702203203.21316-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 Reported-by: Rabi Narayan Sahoo Signed-off-by: Alexander Aring --- net/mac802154/tx.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index 7e253455f9dd..bcd1a5e6ebf4 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -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)); } -- 2.11.0