Skip to content

Commit eabe861

Browse files
MiaoheLindavem330
authored andcommitted
net: handle the return value of pskb_carve_frag_list() correctly
pskb_carve_frag_list() may return -ENOMEM in pskb_carve_inside_nonlinear(). we should handle this correctly or we would get wrong sk_buff. Fixes: 6fa01cc ("skbuff: Add pskb_extract() helper function") Signed-off-by: Miaohe Lin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 989e4da commit eabe861

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

net/core/skbuff.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5987,9 +5987,13 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
59875987
if (skb_has_frag_list(skb))
59885988
skb_clone_fraglist(skb);
59895989

5990-
if (k == 0) {
5991-
/* split line is in frag list */
5992-
pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask);
5990+
/* split line is in frag list */
5991+
if (k == 0 && pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask)) {
5992+
/* skb_frag_unref() is not needed here as shinfo->nr_frags = 0. */
5993+
if (skb_has_frag_list(skb))
5994+
kfree_skb_list(skb_shinfo(skb)->frag_list);
5995+
kfree(data);
5996+
return -ENOMEM;
59935997
}
59945998
skb_release_data(skb);
59955999

0 commit comments

Comments
 (0)