diff mbox series

[net-next] net: gso_test: release each segment individually

Message ID 20231012120240.10447-1-fw@strlen.de (mailing list archive)
State Accepted
Commit 1b2d3b45c1941453703d70f46b70ab8985303b5d
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: gso_test: release each segment individually | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1361 this patch: 1361
netdev/cc_maintainers fail 1 blamed authors not CCed: davem@davemloft.net; 4 maintainers not CCed: kuba@kernel.org davem@davemloft.net pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 1386 this patch: 1386
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1386 this patch: 1386
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Florian Westphal Oct. 12, 2023, 12:02 p.m. UTC
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: b3098d32ed6e ("net: add skb_segment kunit test")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/core/gso_test.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Willem de Bruijn Oct. 12, 2023, 12:27 p.m. UTC | #1
On Thu, Oct 12, 2023 at 8:03 AM Florian Westphal <fw@strlen.de> wrote:
>
> 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: b3098d32ed6e ("net: add skb_segment kunit test")
> Signed-off-by: Florian Westphal <fw@strlen.de>

Reviewed-by: Willem de Bruijn <willemb@google.com>
patchwork-bot+netdevbpf@kernel.org Oct. 17, 2023, 10:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 12 Oct 2023 14:02:37 +0200 you wrote:
> 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: b3098d32ed6e ("net: add skb_segment kunit test")
> Signed-off-by: Florian Westphal <fw@strlen.de>
> 
> [...]

Here is the summary with links:
  - [net-next] net: gso_test: release each segment individually
    https://git.kernel.org/netdev/net-next/c/1b2d3b45c194

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/gso_test.c b/net/core/gso_test.c
index c4b13de6abfb..ceb684be4cbf 100644
--- a/net/core/gso_test.c
+++ b/net/core/gso_test.c
@@ -144,8 +144,8 @@  KUNIT_ARRAY_PARAM(gso_test, cases, gso_test_case_to_desc);
 static void gso_test_func(struct kunit *test)
 {
 	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;
-	struct sk_buff *skb, *segs, *cur;
 	netdev_features_t features;
 	struct page *page;
 	int i;
@@ -236,7 +236,10 @@  static void gso_test_func(struct kunit *test)
 		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]);
 
 		/* segs have skb->data pointing to the mac header */
@@ -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);
 
 		/* last seg can be found through segs->prev pointer */
-		if (!cur->next)
-			KUNIT_ASSERT_PTR_EQ(test, cur, segs->prev);
+		if (!next)
+			KUNIT_ASSERT_PTR_EQ(test, cur, last);
+
+		consume_skb(cur);
 	}
 
 	KUNIT_ASSERT_EQ(test, i, tcase->nr_segs);
 
-	consume_skb(segs);
 free_gso_skb:
 	consume_skb(skb);
 }