Skip to content

Commit 31eff81

Browse files
alexaringdavem330
authored andcommitted
skbuff: fix ftrace handling in skb_unshare
If the skb is not dropped afterwards we should run consume_skb instead kfree_skb. Inside of function skb_unshare we do always a kfree_skb, doesn't depend if skb_copy failed or was successful. This patch switch this behaviour like skb_share_check, if allocation of sk_buff failed we use kfree_skb otherwise consume_skb. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2c2b2f0 commit 31eff81

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/linux/skbuff.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,12 @@ static inline struct sk_buff *skb_unshare(struct sk_buff *skb,
12031203
might_sleep_if(pri & __GFP_WAIT);
12041204
if (skb_cloned(skb)) {
12051205
struct sk_buff *nskb = skb_copy(skb, pri);
1206-
kfree_skb(skb); /* Free our shared copy */
1206+
1207+
/* Free our shared copy */
1208+
if (likely(nskb))
1209+
consume_skb(skb);
1210+
else
1211+
kfree_skb(skb);
12071212
skb = nskb;
12081213
}
12091214
return skb;

0 commit comments

Comments
 (0)