Skip to contentSkip to conversation

bpf: Use kvfree() in xdp_test_run_teardown()

PATCH Applied Zhixing Chen 3 participants 3 messages Sep 3 – Sep 12

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Use kvfree() in xdp_test_run_teardown()

xdp_test_run_setup() allocates xdp->frames and xdp->skbs with kvmalloc_array(). The setup error path already releases both arrays with kvfree(), while the normal teardown path still uses kfree().

Use kvfree() in xdp_test_run_teardown() as well, so the release helper matches the allocator on both paths.

---
 net/bpf/test_run.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/bpf/test_run.c +2 -2
index 5d51f6cb7d15..513354e928cb 100644
@@ -205,8 +205,8 @@ static void xdp_test_run_teardown(struct xdp_test_data *xdp)
 {
 	xdp_unreg_mem_model(&xdp->mem);
 	page_pool_destroy(xdp->pp);
-	kfree(xdp->frames);
-	kfree(xdp->skbs);
+	kvfree(xdp->frames);
+	kvfree(xdp->skbs);
 }
 
 static bool frame_was_changed(const struct xdp_page_head *head)

base-commit: 7bf591f26545f5776a4e42d08c06fd94469766dd

Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Zhixing Chen

xdp_test_run_setup() allocates xdp->frames and xdp->skbs with kvmalloc_array(). The setup error path already releases both arrays with kvfree(), while the normal teardown path still uses kfree().

Use kvfree() in xdp_test_run_teardown() as well, so the release helper matches the allocator on both paths.

---

Quoted 24 lines
 net/bpf/test_run.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/bpf/test_run.c +2 -2
index 5d51f6cb7d15..513354e928cb 100644
@@ -205,8 +205,8 @@ static void xdp_test_run_teardown(struct xdp_test_data *xdp)
 {
        xdp_unreg_mem_model(&xdp->mem);
        page_pool_destroy(xdp->pp);
-       kfree(xdp->frames);
-       kfree(xdp->skbs);
+       kvfree(xdp->frames);
+       kvfree(xdp->skbs);
 }
 
 static bool frame_was_changed(const struct xdp_page_head *head)

base-commit: 7bf591f26545f5776a4e42d08c06fd94469766dd --
2.34.1

#2 lore raw
In reply to Zhixing Chen
This patch was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:

Quoted 8 lines · On Thu, 3 Sep 2026 18:43:58 +0800 you wrote:

xdp_test_run_setup() allocates xdp->frames and xdp->skbs with kvmalloc_array(). The setup error path already releases both arrays with kvfree(), while the normal teardown path still uses kfree().

Use kvfree() in xdp_test_run_teardown() as well, so the release helper matches the allocator on both paths.

[...]

Here is the summary with links:
- [bpf-next] bpf: Use kvfree() in xdp_test_run_teardown()

    https://git.kernel.org/bpf/bpf/c/7d70a0b02d26

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html