diff mbox

[PATCHv4,bluetooth-next,7/8] ieee802154: cleanup WARN_ON for fc fetch

Message ID 20160706213231.23058-8-aar@pengutronix.de (mailing list archive)
State Accepted
Headers show

Commit Message

Alexander Aring July 6, 2016, 9:32 p.m. UTC
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 <aar@pengutronix.de>
---
 include/net/mac802154.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Stefan Schmidt July 8, 2016, 11:23 a.m. UTC | #1
Hello.


On 06/07/16 23:32, Alexander Aring wrote:
> 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<aar@pengutronix.de>
> ---
>   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;


Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>

regards
Stefan Schmidt
--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;