From: Pablo de Lara Date: Thu, 31 May 2018 09:53:07 +0000 (+0100) Subject: net/ixgbe: fix crash on detach X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=beaa005850a27f6e83f30296c1d0893d1ff49925;p=dpdk.git net/ixgbe: fix crash on detach 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 Bugzilla ID: 57 Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports") Cc: stable@dpdk.org Reported-by: Anatoly Burakov Signed-off-by: Pablo de Lara Tested-by: Anatoly Burakov Acked-by: Remy Horton --- diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c index 4d199c8028..c381acf44a 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; }