[dpdk-dev,v3,1/2] librte_ether: release memory in uninit function.
diff mbox

Message ID 1436792645-26831-2-git-send-email-bernard.iremonger@intel.com
State Rejected, archived
Headers show

Commit Message

Iremonger, Bernard July 13, 2015, 1:04 p.m. UTC
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Thomas Monjalon July 17, 2015, 1:55 p.m. UTC | #1
2015-07-13 14:04, Bernard Iremonger:
> @@ -387,8 +387,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));
> +	}

What is the benefit of freeing queues in detach/uninit function?
It is already freed in the close function of your other patch
and calling close() is mandatory before calling detach():
	http://dpdk.org/browse/dpdk/tree/doc/guides/prog_guide/port_hotplug_framework.rst#n63
	http://dpdk.org/browse/dpdk/tree/lib/librte_ether/rte_ethdev.h#n1699

Patch
diff mbox

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b79e5f79..270697e 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -387,8 +387,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;