From: Bastien Curutchet (eBPF Foundation) Date: Fri, 31 Oct 2025 08:04:43 +0000 (+0100) Subject: selftests/bpf: test_xsk: Release resources when swap fails X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f477b0fd75f5e83ceccc166bf53a22641adeb853;p=thirdparty%2Flinux.git selftests/bpf: test_xsk: Release resources when swap fails testapp_validate_traffic() doesn't release the sockets and the umem created by the threads if the test isn't currently in its last step. Thus, if the swap_xsk_resources() fails before the last step, the created resources aren't cleaned up. Clean the sockets and the umem in case of swap_xsk_resources() failure. Reviewed-by: Maciej Fijalkowski Signed-off-by: Bastien Curutchet (eBPF Foundation) Link: https://lore.kernel.org/r/20251031-xsk-v7-7-39fe486593a3@bootlin.com Signed-off-by: Alexei Starovoitov --- diff --git a/tools/testing/selftests/bpf/test_xsk.c b/tools/testing/selftests/bpf/test_xsk.c index 84b724731e26d..8fe75845d7a6a 100644 --- a/tools/testing/selftests/bpf/test_xsk.c +++ b/tools/testing/selftests/bpf/test_xsk.c @@ -1866,8 +1866,13 @@ int testapp_xdp_prog_cleanup(struct test_spec *test) if (testapp_validate_traffic(test)) return TEST_FAILURE; - if (swap_xsk_resources(test)) + if (swap_xsk_resources(test)) { + clean_sockets(test, test->ifobj_rx); + clean_sockets(test, test->ifobj_tx); + clean_umem(test, test->ifobj_rx, test->ifobj_tx); return TEST_FAILURE; + } + return testapp_validate_traffic(test); }