Re: [PATCH bpf-next v1 05/14] selftests/bpf: Fix memory leaks in tests
From: Eduard Zingerman
Date: Thu Feb 12 2026 - 18:08:36 EST
On Wed, 2026-02-11 at 17:13 -0800, Ihor Solodrai wrote:
[...]
> @@ -2005,6 +2005,7 @@ int testapp_stats_rx_full(struct test_spec *test)
> {
> if (pkt_stream_replace(test, DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, MIN_PKT_SIZE))
> return TEST_FAILURE;
> + pkt_stream_delete(test->ifobj_rx->xsk->pkt_stream);
This one is a bit strange.
pkt_stream_replace() allocates test->ifobj_rx->xsk->pkt_stream and
test->ifobj_tx->xsk->pkt_stream (rx and tx streams), and proceeds to
immediately free the rx stream and allocate another one for it.
The following seem to be a better fit:
- if (pkt_stream_replace(test, DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, MIN_PKT_SIZE))
- return TEST_FAILURE;
- pkt_stream_delete(test->ifobj_rx->xsk->pkt_stream);
+ test->ifobj_tx->xsk->pkt_stream = pkt_stream_generate(DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, MIN_PKT_SIZE);
test->ifobj_rx->xsk->pkt_stream = pkt_stream_generate(DEFAULT_UMEM_BUFFERS, MIN_PKT_SIZE);
(I effectively inlined pkt_stream_replace()).
> test->ifobj_rx->xsk->pkt_stream = pkt_stream_generate(DEFAULT_UMEM_BUFFERS, MIN_PKT_SIZE);
>
> test->ifobj_rx->xsk->rxqsize = DEFAULT_UMEM_BUFFERS;
> @@ -2017,6 +2018,7 @@ int testapp_stats_fill_empty(struct test_spec *test)
> {
> if (pkt_stream_replace(test, DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, MIN_PKT_SIZE))
> return TEST_FAILURE;
> + pkt_stream_delete(test->ifobj_rx->xsk->pkt_stream);
> test->ifobj_rx->xsk->pkt_stream = pkt_stream_generate(DEFAULT_UMEM_BUFFERS, MIN_PKT_SIZE);
Same here.
[...]