Commit 1b2d3b45 authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

net: gso_test: release each segment individually

consume_skb() doesn't walk the segment list, so segments other than
the first are leaked.

Move this skb_consume call into the loop.

Cc: Willem de Bruijn <willemb@google.com>
Fixes: b3098d32 ("net: add skb_segment kunit test")
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a3c2dd96
...@@ -144,8 +144,8 @@ KUNIT_ARRAY_PARAM(gso_test, cases, gso_test_case_to_desc); ...@@ -144,8 +144,8 @@ KUNIT_ARRAY_PARAM(gso_test, cases, gso_test_case_to_desc);
static void gso_test_func(struct kunit *test) static void gso_test_func(struct kunit *test)
{ {
const int shinfo_size = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); const int shinfo_size = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
struct sk_buff *skb, *segs, *cur, *next, *last;
const struct gso_test_case *tcase; const struct gso_test_case *tcase;
struct sk_buff *skb, *segs, *cur;
netdev_features_t features; netdev_features_t features;
struct page *page; struct page *page;
int i; int i;
...@@ -236,7 +236,10 @@ static void gso_test_func(struct kunit *test) ...@@ -236,7 +236,10 @@ static void gso_test_func(struct kunit *test)
goto free_gso_skb; goto free_gso_skb;
} }
for (cur = segs, i = 0; cur; cur = cur->next, i++) { last = segs->prev;
for (cur = segs, i = 0; cur; cur = next, i++) {
next = cur->next;
KUNIT_ASSERT_EQ(test, cur->len, sizeof(hdr) + tcase->segs[i]); KUNIT_ASSERT_EQ(test, cur->len, sizeof(hdr) + tcase->segs[i]);
/* segs have skb->data pointing to the mac header */ /* segs have skb->data pointing to the mac header */
...@@ -247,13 +250,14 @@ static void gso_test_func(struct kunit *test) ...@@ -247,13 +250,14 @@ static void gso_test_func(struct kunit *test)
KUNIT_ASSERT_EQ(test, memcmp(skb_mac_header(cur), hdr, sizeof(hdr)), 0); KUNIT_ASSERT_EQ(test, memcmp(skb_mac_header(cur), hdr, sizeof(hdr)), 0);
/* last seg can be found through segs->prev pointer */ /* last seg can be found through segs->prev pointer */
if (!cur->next) if (!next)
KUNIT_ASSERT_PTR_EQ(test, cur, segs->prev); KUNIT_ASSERT_PTR_EQ(test, cur, last);
consume_skb(cur);
} }
KUNIT_ASSERT_EQ(test, i, tcase->nr_segs); KUNIT_ASSERT_EQ(test, i, tcase->nr_segs);
consume_skb(segs);
free_gso_skb: free_gso_skb:
consume_skb(skb); consume_skb(skb);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment