vhost: delete freeing mac_addrs in eth_dev_close

Message ID 201812181015.wBIAFlYk016726@ccmail04.silk.ntt-tx.co.jp (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vhost: delete freeing mac_addrs in eth_dev_close |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Hideyuki Yamashita Dec. 18, 2018, 10:14 a.m. UTC
  From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

When rte_dev_remove is called for vhost, eth_dev_close and
rte_eth_dev_release_port is called.
Both eth_dev_close and rte_eth_dev_release_port calls rte_free
for same data area(mac_addrs) and thus causes double free.
This patch fixes this by deleting rte_free for mac_addrs.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
---
 drivers/net/vhost/rte_eth_vhost.c | 1 -
 1 file changed, 1 deletion(-)
  

Comments

Tiwei Bie Dec. 18, 2018, 1:02 p.m. UTC | #1
> vhost: delete freeing mac_addrs in eth_dev_close

We are changing vhost PMD, so the component name is net/vhost.
And generally we avoid using _ in title (devtools/check-git-log.sh
can help do the check). So something like this will be better:

net/vhost: fix double free of MAC addrs

On Tue, Dec 18, 2018 at 07:14:30PM +0900, Hideyuki Yamashita wrote:
> From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
> 
> When rte_dev_remove is called for vhost, eth_dev_close and
> rte_eth_dev_release_port is called.
> Both eth_dev_close and rte_eth_dev_release_port calls rte_free
> for same data area(mac_addrs) and thus causes double free.
> This patch fixes this by deleting rte_free for mac_addrs.

It will be better to explain why rte_free() in eth_dev_close()
instead of rte_eth_dev_release_port() should be removed. So
having something like this in commit log will help others to
have a better understanding of the background:

"""
The common data freeing has been moved to rte_eth_dev_release_port(),
so freeing mac_addrs like this in eth_dev_close() is unnecessary and
will cause double free.
"""

And as this is a fix, we need a "Fixes" line and also cc stable:

Fixes: e16adf08e54d ("ethdev: free all common data when releasing port")
Cc: stable@dpdk.org

Besides, it would be better to put maintainers (which can be
got by devtools/get-maintainer.sh) in the Cc or To list when
sending the patch to get their attention.

Thanks for the contribution!

> 
> Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
> ---
>  drivers/net/vhost/rte_eth_vhost.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index 42bdfcbd5..b2cda0483 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -1000,7 +1000,6 @@ eth_dev_close(struct rte_eth_dev *dev)
>  		for (i = 0; i < dev->data->nb_tx_queues; i++)
>  			rte_free(dev->data->tx_queues[i]);
>  
> -	rte_free(dev->data->mac_addrs);
>  	free(internal->dev_name);
>  	free(internal->iface_name);
>  	rte_free(internal);
> -- 
> 2.18.0
> 
> 
>
  

Patch

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 42bdfcbd5..b2cda0483 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -1000,7 +1000,6 @@  eth_dev_close(struct rte_eth_dev *dev)
 		for (i = 0; i < dev->data->nb_tx_queues; i++)
 			rte_free(dev->data->tx_queues[i]);
 
-	rte_free(dev->data->mac_addrs);
 	free(internal->dev_name);
 	free(internal->iface_name);
 	rte_free(internal);