summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2020-08-15 04:46:41 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-23 12:40:34 +0200
commit78607d494c92641b38323b59b25cdc750d1ec7bf (patch)
tree644ea8bdd5831f657b1625048498d016a6b4f4e6 /net/core
parentb3dacce5025c760c6920af6ff38ffd90d3b3c4d7 (diff)
net: handle the return value of pskb_carve_frag_list() correctly
commit eabe861881a733fc84f286f4d5a1ffaddd4f526f upstream. 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: 6fa01ccd8830 ("skbuff: Add pskb_extract() helper function") Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/skbuff.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f80b6999ca1c..08d9915d50c0 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5882,9 +5882,13 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
if (skb_has_frag_list(skb))
skb_clone_fraglist(skb);
- if (k == 0) {
- /* split line is in frag list */
- pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask);
+ /* split line is in frag list */
+ if (k == 0 && pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask)) {
+ /* skb_frag_unref() is not needed here as shinfo->nr_frags = 0. */
+ if (skb_has_frag_list(skb))
+ kfree_skb_list(skb_shinfo(skb)->frag_list);
+ kfree(data);
+ return -ENOMEM;
}
skb_release_data(skb);