netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1 -next] 6LoWPAN: fix skb_copy call
@ 2011-09-01 12:21 Alexander Smirnov
  2011-09-01 11:30 ` Eric Dumazet
       [not found] ` <1314879675-31989-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Alexander Smirnov @ 2011-09-01 12:21 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

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 depending on context.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 net/ieee802154/6lowpan.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index cf304cc..cac1361 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -477,9 +477,15 @@ static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr)
 	struct sk_buff *new;
 	struct lowpan_dev_record *entry;
 	int stat = NET_RX_SUCCESS;
+	gfp_t mask;
 
-	new = skb_copy_expand(skb, sizeof(struct ipv6hdr), skb_tailroom(skb),
-								GFP_KERNEL);
+	if (in_interrupt())
+		mask = GFP_ATOMIC;
+	else
+		mask = GFP_KERNEL;
+
+	new = skb_copy_expand(skb, sizeof(struct ipv6hdr),
+					skb_tailroom(skb), mask);
 	kfree_skb(skb);
 
 	if (NULL == new)
@@ -495,7 +501,13 @@ 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 = skb_copy(new, mask);
+
+			if (NULL == skb) {
+				kfree_skb(new);
+				return -ENOMEM;
+			}
+
 			skb->dev = entry->ldev;
 
 			if (in_interrupt())
-- 
1.7.2.5


------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-09-15 19:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-01 12:21 [PATCH 1/1 -next] 6LoWPAN: fix skb_copy call Alexander Smirnov
2011-09-01 11:30 ` Eric Dumazet
     [not found] ` <1314879675-31989-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-01 12:54   ` [PATCH v2 " Alexander Smirnov
2011-09-01 12:00     ` Eric Dumazet
2011-09-01 12:34       ` Alexander Smirnov
2011-09-01 12:10     ` Daniel Baluta
     [not found]     ` <1314881653-1104-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-15 19:42       ` David Miller
2011-09-01 13:55   ` [PATCH v3 " Alexander Smirnov
2011-09-01 15:31     ` Eric Dumazet
     [not found]     ` <1314885315-4033-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-15 19:43       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).