[dpdk-dev] net/ixgbe: fix crash on detach

Message ID 20180530063156.17902-1-pablo.de.lara.guarch@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers

Checks

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

Commit Message

De Lara Guarch, Pablo May 30, 2018, 6:31 a.m. UTC
  When detaching a port bound to ixgbe PMD, if the port
does not have any VFs, *vfinfo is not set and there is
a NULL dereference attempt, when calling
rte_eth_switch_domain_free(), which expects VFs to be used,
causing a segmentation fault.

Steps to reproduce:

./testpmd -- -i
testpmd> port stop all
testpmd> port close all
testpmd> port detach 0

Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")

Reported-by: Anatoly Burakov <anatoly.burakov@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/net/ixgbe/ixgbe_pf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Anatoly Burakov May 30, 2018, 2:48 p.m. UTC | #1
On 30-May-18 7:31 AM, Pablo de Lara wrote:
> When detaching a port bound to ixgbe PMD, if the port
> does not have any VFs, *vfinfo is not set and there is
> a NULL dereference attempt, when calling
> rte_eth_switch_domain_free(), which expects VFs to be used,
> causing a segmentation fault.
> 
> Steps to reproduce:
> 
> ./testpmd -- -i
> testpmd> port stop all
> testpmd> port close all
> testpmd> port detach 0
> 
> Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
> 
> Reported-by: Anatoly Burakov <anatoly.burakov@intel.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---

Tested-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
Remy Horton May 30, 2018, 3:21 p.m. UTC | #2
On 30/05/2018 07:31, Pablo de Lara wrote:
[..]
> Reported-by: Anatoly Burakov <anatoly.burakov@intel.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Acked-by: Remy Horton <remy.horton@intel.com>
  
Ferruh Yigit May 30, 2018, 5:49 p.m. UTC | #3
On 5/30/2018 4:21 PM, Remy Horton wrote:
> 
> On 30/05/2018 07:31, Pablo de Lara wrote:
> [..]
>> Reported-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> 
> Acked-by: Remy Horton <remy.horton@intel.com>

The fix was late for the release.

A patch to document issue as known issue for this release sent:
https://dpdk.org/dev/patchwork/patch/40520/
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index 4d199c802..c381acf44 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -135,14 +135,14 @@  void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
 	RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx = 0;
 	RTE_ETH_DEV_SRIOV(eth_dev).def_pool_q_idx = 0;
 
-	ret = rte_eth_switch_domain_free((*vfinfo)->switch_domain_id);
-	if (ret)
-		PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
-
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
 		return;
 
+	ret = rte_eth_switch_domain_free((*vfinfo)->switch_domain_id);
+	if (ret)
+		PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
+
 	rte_free(*vfinfo);
 	*vfinfo = NULL;
 }