Skip to contentSkip to conversation

skbuff: use kfree_skb() instead of kfree()

PATCH In review Dan Carpenter 5 participants 10 messages Jul 20, 2011 – Jul 21, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 skbuff: use kfree_skb() instead of kfree()

"n" was allocated with alloc_skb() so we should free it with kfree_skb() instead of regular kfree().

net/core/skbuff.c +1 -1
index d220119..cc0c6f0 100644
@@ -799,7 +799,7 @@ 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);
 				goto out;
 			}
 			skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY;
#1 lore raw

Crap. Sorry, I shouldn't have sent that. We shouldn't return the freed "n" here. I'll send a v2 shortly.

regards,
dan carpenter

#2 lore raw
Quoted 2 lines · Dan Carpenter

Crap. Sorry, I shouldn't have sent that. We shouldn't return the freed "n" here. I'll send a v2 shortly.

Also, dont forget to say its a patch for net-next-2.6

The recommended way is to use

[PATCH net-next-2.6] ...

#3 lore raw
Quoted 5 lines · Eric Dumazet
Quoted 2 lines · Dan Carpenter

Crap. Sorry, I shouldn't have sent that. We shouldn't return the freed "n" here. I'll send a v2 shortly.

Also, dont forget to say its a patch for net-next-2.6

If you're using linux-next, is there a way to tell which tree a patch came from? Obviously in this case it's core networking, but in other cases how does that work?

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 10 lines · Dan Carpenter
Quoted 5 lines · Eric Dumazet
Quoted 2 lines · Dan Carpenter

Crap. Sorry, I shouldn't have sent that. We shouldn't return the freed "n" here. I'll send a v2 shortly.

Also, dont forget to say its a patch for net-next-2.6

If you're using linux-next, is there a way to tell which tree a patch came from? Obviously in this case it's core networking, but in other cases how does that work?

In this particular case, David will know for sure since patch is very recent, but I wanted to make a general advice.

Keep in mind David has to review dozens of patches _per_ day, so netdev related patches need some extra cooperation from submitters to help the maintainer.

This extra cooperation means to test the patch on either net-next-2.6 or net-2.6 tree ;)

#5 lore raw
Quoted 15 lines · Eric Dumazet
Quoted 10 lines · Dan Carpenter
Quoted 5 lines · Eric Dumazet
Quoted 2 lines · Dan Carpenter

Crap. Sorry, I shouldn't have sent that. We shouldn't return the freed "n" here. I'll send a v2 shortly.

Also, dont forget to say its a patch for net-next-2.6

If you're using linux-next, is there a way to tell which tree a patch came from? Obviously in this case it's core networking, but in other cases how does that work?

In this particular case, David will know for sure since patch is very recent, but I wanted to make a general advice.

Quoted 6 lines

Keep in mind David has to review dozens of patches _per_ day, so netdev related patches need some extra cooperation from submitters to help the maintainer.

This extra cooperation means to test the patch on either net-next-2.6 or net-2.6 tree ;)

Maybe there is some way to integrate such a suggestion in get_maintainers or checkpatch? Otherwise, those who work on the code in a more breadth first way don't have much chance of knowing or remembering this advice.

julia

#6 lore raw
Quoted 13 lines
Quoted 13 lines
Quoted 5 lines
Quoted 1 line

Also, dont forget to say its a patch for net-next-2.6

If you're using linux-next, is there a way to tell which tree a patch came from?  Obviously in this case it's core networking, but in other cases how does that work?

In this particular case, David will know for sure since patch is very recent, but I wanted to make a general advice.

Keep in mind David has to review dozens of patches _per_ day, so netdev related patches need some extra cooperation from submitters to help the maintainer.

Quoted 8 lines
Quoted 2 lines

This extra cooperation means to test the patch on either net-next-2.6 or net-2.6 tree ;)

Maybe there is some way to integrate such a suggestion in get_maintainers or checkpatch?  Otherwise, those who work on the code in a more breadth first way don't have much chance of knowing or remembering this advice.

julia

I think Julia's observation is really on the nail, I wish there were some way of doing this? If new or random testers or reviewers out there aren't tracking/following a particular tree/project already - i.e. if they don't _know_ beforehand, aren't they going to just assume using linux-next is correct (at least that's what I do)? Knowing what branch to most productively test patches against beforehand might encourage more testers and submissions and also could make maintainer's jobs a bit easier.

Cheers
Julie
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

PATCH v2 1/1 skbuff: fix error handling in pskb_copy()

In reply to Dan Carpenter

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.

net/core/skbuff.c +2 -1
index d220119..2beda82 100644
@@ -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;
Reviewed-by on v2 1/1
#8 lore raw

Re: [patch net-next-2.6 v2] skbuff: fix error handling in pskb_copy()

Quoted 6 lines · Dan Carpenter

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.

Thanks Dan

maintainer
#9 lore raw

Re: [patch net-next-2.6 v2] skbuff: fix error handling in pskb_copy()

From: Eric Dumazet <[email protected]>
Date: Wed, 20 Jul 2011 10:59:46 +0200

Quoted 11 lines · Dan Carpenter
Quoted 6 lines

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.

Thanks Dan

Applied, thanks everyone.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html