[dpdk-dev,v3,1/2] net/i40e: fix segmentation fault in close

Message ID 1484229492-18902-2-git-send-email-bernard.iremonger@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation success Compilation OK

Commit Message

Iremonger, Bernard Jan. 12, 2017, 1:58 p.m. UTC
  Change the order of releasing the vsi's.
Release the vmdq vsi's first, then release the main vsi.

Fixes: 4861cde46116 ("i40e: new poll mode driver")

CC: stable@dpdk.org

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
  

Comments

Jingjing Wu Jan. 17, 2017, 2:34 p.m. UTC | #1
> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Thursday, January 12, 2017 9:58 PM
> To: dev@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Zhang, Helin <helin.zhang@intel.com>
> Cc: Iremonger, Bernard <bernard.iremonger@intel.com>; stable@dpdk.org
> Subject: [PATCH v3 1/2] net/i40e: fix segmentation fault in close
> 
> Change the order of releasing the vsi's.
> Release the vmdq vsi's first, then release the main vsi.
> 
> Fixes: 4861cde46116 ("i40e: new poll mode driver")
> 
> CC: stable@dpdk.org
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index f13e61b..e8cfec8 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -2068,18 +2068,17 @@ i40e_dev_close(struct rte_eth_dev *dev)
>  	/* shutdown and destroy the HMC */
>  	i40e_shutdown_lan_hmc(hw);
> 
> -	/* release all the existing VSIs and VEBs */
> -	i40e_fdir_teardown(pf);
> -	i40e_vsi_release(pf->main_vsi);
> -
>  	for (i = 0; i < pf->nb_cfg_vmdq_vsi; i++) {
>  		i40e_vsi_release(pf->vmdq[i].vsi);
>  		pf->vmdq[i].vsi = NULL;
>  	}
> -
>  	rte_free(pf->vmdq);
>  	pf->vmdq = NULL;
> 
> +	/* release all the existing VSIs and VEBs */
> +	i40e_fdir_teardown(pf);
> +	i40e_vsi_release(pf->main_vsi);
> +
>  	/* shutdown the adminq */
>  	i40e_aq_queue_shutdown(hw, true);
>  	i40e_shutdown_adminq(hw);
> @@ -4342,6 +4341,9 @@ i40e_vsi_release(struct i40e_vsi *vsi)
>  	if (!vsi)
>  		return I40E_SUCCESS;
> 
> +	if (!vsi->adapter)
> +		return I40E_ERR_BAD_PTR;
> +

The change looks fine to me.
Only minor comments like:
The dev_close is ethdev level ops, I40E_XX error code need to be replaced by 
The error code defined in ethedev level.
  
Iremonger, Bernard Jan. 17, 2017, 4:30 p.m. UTC | #2
Hi Jingjing,

<snip>

> > Subject: [PATCH v3 1/2] net/i40e: fix segmentation fault in close
> >
> > Change the order of releasing the vsi's.
> > Release the vmdq vsi's first, then release the main vsi.
> >
> > Fixes: 4861cde46116 ("i40e: new poll mode driver")
> >
> > CC: stable@dpdk.org
> >
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > ---
> >  drivers/net/i40e/i40e_ethdev.c | 12 +++++++-----
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > b/drivers/net/i40e/i40e_ethdev.c index f13e61b..e8cfec8 100644
> > --- a/drivers/net/i40e/i40e_ethdev.c
> > +++ b/drivers/net/i40e/i40e_ethdev.c
> > @@ -2068,18 +2068,17 @@ i40e_dev_close(struct rte_eth_dev *dev)
> >  	/* shutdown and destroy the HMC */
> >  	i40e_shutdown_lan_hmc(hw);
> >
> > -	/* release all the existing VSIs and VEBs */
> > -	i40e_fdir_teardown(pf);
> > -	i40e_vsi_release(pf->main_vsi);
> > -
> >  	for (i = 0; i < pf->nb_cfg_vmdq_vsi; i++) {
> >  		i40e_vsi_release(pf->vmdq[i].vsi);
> >  		pf->vmdq[i].vsi = NULL;
> >  	}
> > -
> >  	rte_free(pf->vmdq);
> >  	pf->vmdq = NULL;
> >
> > +	/* release all the existing VSIs and VEBs */
> > +	i40e_fdir_teardown(pf);
> > +	i40e_vsi_release(pf->main_vsi);
> > +
> >  	/* shutdown the adminq */
> >  	i40e_aq_queue_shutdown(hw, true);
> >  	i40e_shutdown_adminq(hw);
> > @@ -4342,6 +4341,9 @@ i40e_vsi_release(struct i40e_vsi *vsi)
> >  	if (!vsi)
> >  		return I40E_SUCCESS;
> >
> > +	if (!vsi->adapter)
> > +		return I40E_ERR_BAD_PTR;
> > +
> 
> The change looks fine to me.
> Only minor comments like:
> The dev_close is ethdev level ops, I40E_XX error code need to be replaced
> by The error code defined in ethedev level.

I will replace I40E_ERR_BAD_PTR with -EFAULT in v4.

Regards,

Bernard.
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f13e61b..e8cfec8 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2068,18 +2068,17 @@  i40e_dev_close(struct rte_eth_dev *dev)
 	/* shutdown and destroy the HMC */
 	i40e_shutdown_lan_hmc(hw);
 
-	/* release all the existing VSIs and VEBs */
-	i40e_fdir_teardown(pf);
-	i40e_vsi_release(pf->main_vsi);
-
 	for (i = 0; i < pf->nb_cfg_vmdq_vsi; i++) {
 		i40e_vsi_release(pf->vmdq[i].vsi);
 		pf->vmdq[i].vsi = NULL;
 	}
-
 	rte_free(pf->vmdq);
 	pf->vmdq = NULL;
 
+	/* release all the existing VSIs and VEBs */
+	i40e_fdir_teardown(pf);
+	i40e_vsi_release(pf->main_vsi);
+
 	/* shutdown the adminq */
 	i40e_aq_queue_shutdown(hw, true);
 	i40e_shutdown_adminq(hw);
@@ -4342,6 +4341,9 @@  i40e_vsi_release(struct i40e_vsi *vsi)
 	if (!vsi)
 		return I40E_SUCCESS;
 
+	if (!vsi->adapter)
+		return I40E_ERR_BAD_PTR;
+
 	user_param = vsi->user_param;
 
 	pf = I40E_VSI_TO_PF(vsi);