Skip to contentSkip to conversation

net/ixgbe: fix missing NULL point check

PATCH Superseded Qi Zhang 2 participants 2 messages Jul 2, 2018 – Jul 12, 2018 Network drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Qi Zhang

author
#0 lore raw

PATCH 1/1 net/ixgbe: fix missing NULL point check

Add missing NULL point check in ixgbe_pf_host_uninit, or it may cause segement fault when detach a device.

Fixes cf80ba6e2038 ("net/ixgbe: add support for representor ports")
---
 drivers/net/ixgbe/ixgbe_pf.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +9 -6
index 4d199c8..73f0e43 100644
@@ -128,21 +128,24 @@ 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;
 	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;
 
+	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);
+
 	rte_free(*vfinfo);
 	*vfinfo = NULL;
 }
Signature · 1 line
2.5.5
#1 lore raw

Patch doesn't apply to latest master, but otherwise seems fine to me.

Quoted 7 lines · Qi Zhang

Add missing NULL point check in ixgbe_pf_host_uninit, or it may cause segement fault when detach a device.

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