skbuff: fix error handling in pskb_copy()
authorDan Carpenter <error27@gmail.com>
Tue, 19 Jul 2011 22:51:49 +0000 (22:51 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Jul 2011 21:47:54 +0000 (14:47 -0700)
There are two problems:
1) "n" was allocated with alloc_skb() so we should free it with
   kfree_skb() instead of regular kfree().
2) We return the freed pointer instead of NULL.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skbuff.c

index d220119f13ab7601244cce9060f56d2d22213077..2beda824636e7d270c8a8f24f2e084cfdef75ab4 100644 (file)
@@ -799,7 +799,8 @@ struct sk_buff *pskb_copy(struct sk_buff *skb, gfp_t gfp_mask)
 
                if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
                        if (skb_copy_ubufs(skb, gfp_mask)) {
-                               kfree(n);
+                               kfree_skb(n);
+                               n = NULL;
                                goto out;
                        }
                        skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY;