From: alex.bluesman.smirnov@gmail.com Date: Thu, 1 Sep 2011 03:55:15 +0000 (+0000) Subject: 6LoWPAN: fix skb_copy call X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=dcef1151804257684f65c779fc1c19836ee0196a;p=openwrt%2Fstaging%2Fblogic.git 6LoWPAN: fix skb_copy call This patch fixes 2 issues in lowpan_skb_deliver function: 1. Check for return status of skb_copy call; 2. Use skb_copy with proper GFP flag, drop check for non-interrupt context. Signed-off-by: Alexander Smirnov Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index f0d15365722a..19d6aefe97d4 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -479,10 +479,10 @@ static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr) int stat = NET_RX_SUCCESS; new = skb_copy_expand(skb, sizeof(struct ipv6hdr), skb_tailroom(skb), - GFP_KERNEL); + GFP_ATOMIC); kfree_skb(skb); - if (NULL == new) + if (!new) return -ENOMEM; skb_push(new, sizeof(struct ipv6hdr)); @@ -495,13 +495,14 @@ static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr) rcu_read_lock(); list_for_each_entry_rcu(entry, &lowpan_devices, list) if (lowpan_dev_info(entry->ldev)->real_dev == new->dev) { - skb = skb_copy(new, GFP_KERNEL); - skb->dev = entry->ldev; + skb = skb_copy(new, GFP_ATOMIC); + if (!skb) { + stat = -ENOMEM; + break; + } - if (in_interrupt()) - stat = netif_rx(skb); - else - stat = netif_rx_ni(skb); + skb->dev = entry->ldev; + stat = netif_rx(skb); } rcu_read_unlock();