|SUCCESS| net/af_xdp: fix resource leak in eth_dev_close

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Tue Apr 7 11:44:04 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/162885

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-07

git sha: F8BAB5327DFA4F53+20260403124053.1354-1-ouyanghao at tencent.com
Author: Ouyang Hao <ouyanghao at tencent.com>
Subject: [PATCH] net/af_xdp: fix resource leak in eth_dev_close

This patch fixes a resource leak in the AF_XDP PMD's eth_dev_close()
function. The rx_queues and tx_queues arrays are allocated as contiguous
blocks but were being freed incorrectly on a per-element basis, causing
queue cleanup to fail after the first iteration.

> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 10dbcf1333..2cdb533276 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -1069,12 +1069,10 @@ eth_dev_close(struct rte_eth_dev *dev)
>  		if (rte_atomic_fetch_sub_explicit(&rxq->umem->refcnt, 1,
>  				rte_memory_order_acquire) - 1 == 0)
>  			xdp_umem_destroy(rxq->umem);
> -
> -		/* free pkt_tx_queue */
> -		rte_free(rxq->pair);
> -		rte_free(rxq);

The removal of rte_free(rxq->pair) raises a question. If rxq->pair points
to dynamically allocated memory that is separate from the contiguous
tx_queues array allocation, does this code now leak rxq->pair for all
queues? Can you verify that rxq->pair is not independently allocated and
does not need to be freed separately?

>  	}
> -
> +	/* Free Tx and Rx queue arrays */
> +	rte_free(internals->tx_queues);
> +	rte_free(internals->rx_queues);

Does the code iterate over all tx_queues to perform cleanup, or does it
only iterate over rx_queues? If tx_queues elements require per-queue
cleanup (similar to the XSK socket deletion and UMEM reference counting
done for rx_queues), does this code skip that cleanup entirely?

>  	/*
>  	 * MAC is not allocated dynamically, setting it to NULL would prevent
>  	 * from releasing it in rte_eth_dev_release_port.


More information about the test-report mailing list