net/ixgbe: fix missing null check on detach
authorQi Zhang <qi.z.zhang@intel.com>
Mon, 16 Jul 2018 12:47:04 +0000 (20:47 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 23 Jul 2018 21:55:26 +0000 (23:55 +0200)
Add missing NULL point check inside ixgbe_pf_host_uninit, or it may cause
segment fault when detaching a device.

Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
Cc: stable@dpdk.org
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
drivers/net/ixgbe/ixgbe_pf.c

index c381acf..4b833ff 100644 (file)
@@ -128,8 +128,6 @@ void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
 
        PMD_INIT_FUNC_TRACE();
 
-       vfinfo = IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
-
        RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
        RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = 0;
        RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx = 0;
@@ -139,6 +137,10 @@ void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
        if (vf_num == 0)
                return;
 
+       vfinfo = IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
+       if (*vfinfo == NULL)
+               return;
+
        ret = rte_eth_switch_domain_free((*vfinfo)->switch_domain_id);
        if (ret)
                PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);