[dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.

Qiu, Michael michael.qiu at intel.com
Mon Jun 29 10:54:50 CEST 2015


On 6/26/2015 5:32 PM, Iremonger, Bernard wrote:
> Changes in v2:
> do not free mac_addrs and hash_mac_addrs here.
>
> Signed-off-by: Bernard Iremonger <bernard.iremonger at intel.com>
> ---
>  lib/librte_ether/rte_ethdev.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index e13fde5..7ae101a 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
>  	/* free ether device */
>  	rte_eth_dev_release_port(eth_dev);
>  
> -	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> +	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +		rte_free(eth_dev->data->rx_queues);
> +		rte_free(eth_dev->data->tx_queues);
>  		rte_free(eth_dev->data->dev_private);
> +		memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
> +	}
>  
>  	eth_dev->pci_dev = NULL;
>  	eth_dev->driver = NULL;


Actually, This could be put in rte_eth_dev_close() becasue queues should
be released when closed.

Also before free dev->data->rx_queues you should make sure
dev->data->rx_queues[i] has been freed in PMD close() function, So this
two should be better done at the same time, ether in 
rte_eth_dev_close() or in PMD close() function. For hotplug in fm10k, I
put it in PMD close() function.
 
Thanks,
Michael


More information about the dev mailing list