From patchwork Wed Jul 6 21:32:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 9217091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 786906048B for ; Wed, 6 Jul 2016 21:32:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E0AC2849D for ; Wed, 6 Jul 2016 21:32:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62D972849E; Wed, 6 Jul 2016 21:32:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C75842849F for ; Wed, 6 Jul 2016 21:32:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755769AbcGFVcu (ORCPT ); Wed, 6 Jul 2016 17:32:50 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:58596 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755800AbcGFVct (ORCPT ); Wed, 6 Jul 2016 17:32:49 -0400 Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=omega.localdomain) by metis.ext.pengutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1bKuR6-00049J-Dh; Wed, 06 Jul 2016 23:32:48 +0200 From: Alexander Aring To: linux-wpan@vger.kernel.org Cc: kernel@pengutronix.de, Alexander Aring Subject: [PATCHv4 bluetooth-next 7/8] ieee802154: cleanup WARN_ON for fc fetch Date: Wed, 6 Jul 2016 23:32:30 +0200 Message-Id: <20160706213231.23058-8-aar@pengutronix.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160706213231.23058-1-aar@pengutronix.de> References: <20160706213231.23058-1-aar@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: aar@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-wpan@vger.kernel.org Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch cleanups the WARN_ON which occurs when the sk buffer has insufficient buffer space by moving the WARN_ON into if condition. Signed-off-by: Alexander Aring Reviewed-by: Stefan Schmidt --- include/net/mac802154.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/net/mac802154.h b/include/net/mac802154.h index bb7bfec..286824a 100644 --- a/include/net/mac802154.h +++ b/include/net/mac802154.h @@ -250,11 +250,10 @@ static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb) __le16 fc; /* check if we can fc at skb_mac_header of sk buffer */ - if (unlikely(!skb_mac_header_was_set(skb) || - (skb_tail_pointer(skb) - skb_mac_header(skb)) < 2)) { - WARN_ON(1); + if (WARN_ON(!skb_mac_header_was_set(skb) || + (skb_tail_pointer(skb) - + skb_mac_header(skb)) < IEEE802154_FC_LEN)) return cpu_to_le16(0); - } memcpy(&fc, skb_mac_header(skb), IEEE802154_FC_LEN); return fc;