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 <alex.bluesman.smirnov@gmail.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
fa3df928e0
commit
dcef115180
@@ -479,10 +479,10 @@ static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr)
|
|||||||
int stat = NET_RX_SUCCESS;
|
int stat = NET_RX_SUCCESS;
|
||||||
|
|
||||||
new = skb_copy_expand(skb, sizeof(struct ipv6hdr), skb_tailroom(skb),
|
new = skb_copy_expand(skb, sizeof(struct ipv6hdr), skb_tailroom(skb),
|
||||||
GFP_KERNEL);
|
GFP_ATOMIC);
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
|
|
||||||
if (NULL == new)
|
if (!new)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
skb_push(new, sizeof(struct ipv6hdr));
|
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();
|
rcu_read_lock();
|
||||||
list_for_each_entry_rcu(entry, &lowpan_devices, list)
|
list_for_each_entry_rcu(entry, &lowpan_devices, list)
|
||||||
if (lowpan_dev_info(entry->ldev)->real_dev == new->dev) {
|
if (lowpan_dev_info(entry->ldev)->real_dev == new->dev) {
|
||||||
skb = skb_copy(new, GFP_KERNEL);
|
skb = skb_copy(new, GFP_ATOMIC);
|
||||||
skb->dev = entry->ldev;
|
if (!skb) {
|
||||||
|
stat = -ENOMEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (in_interrupt())
|
skb->dev = entry->ldev;
|
||||||
stat = netif_rx(skb);
|
stat = netif_rx(skb);
|
||||||
else
|
|
||||||
stat = netif_rx_ni(skb);
|
|
||||||
}
|
}
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user