Skip to content

Commit 1b2d3b4

Browse files
Florian Westphaldavem330
authored andcommitted
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 <[email protected]> Fixes: b3098d3 ("net: add skb_segment kunit test") Signed-off-by: Florian Westphal <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a3c2dd9 commit 1b2d3b4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

net/core/gso_test.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ KUNIT_ARRAY_PARAM(gso_test, cases, gso_test_case_to_desc);
144144
static void gso_test_func(struct kunit *test)
145145
{
146146
const int shinfo_size = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
147+
struct sk_buff *skb, *segs, *cur, *next, *last;
147148
const struct gso_test_case *tcase;
148-
struct sk_buff *skb, *segs, *cur;
149149
netdev_features_t features;
150150
struct page *page;
151151
int i;
@@ -236,7 +236,10 @@ static void gso_test_func(struct kunit *test)
236236
goto free_gso_skb;
237237
}
238238

239-
for (cur = segs, i = 0; cur; cur = cur->next, i++) {
239+
last = segs->prev;
240+
for (cur = segs, i = 0; cur; cur = next, i++) {
241+
next = cur->next;
242+
240243
KUNIT_ASSERT_EQ(test, cur->len, sizeof(hdr) + tcase->segs[i]);
241244

242245
/* segs have skb->data pointing to the mac header */
@@ -247,13 +250,14 @@ static void gso_test_func(struct kunit *test)
247250
KUNIT_ASSERT_EQ(test, memcmp(skb_mac_header(cur), hdr, sizeof(hdr)), 0);
248251

249252
/* last seg can be found through segs->prev pointer */
250-
if (!cur->next)
251-
KUNIT_ASSERT_PTR_EQ(test, cur, segs->prev);
253+
if (!next)
254+
KUNIT_ASSERT_PTR_EQ(test, cur, last);
255+
256+
consume_skb(cur);
252257
}
253258

254259
KUNIT_ASSERT_EQ(test, i, tcase->nr_segs);
255260

256-
consume_skb(segs);
257261
free_gso_skb:
258262
consume_skb(skb);
259263
}

0 commit comments

Comments
 (0)