net/ice: fix crash on representor port closing

If DCF representor port is closed after DCF port is closed, there will
be segmentation fault because representor accesses the released resource
of DCF port.

This patch checks if the resource is present before accessing.

Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
Cc: stable@dpdk.org

Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
This commit is contained in:
Dapeng Yu 2021-09-07 10:00:33 +08:00 committed by Qi Zhang
parent f979702337
commit da9cdcd1f3

View File

@ -114,6 +114,11 @@ ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr)
struct ice_dcf_adapter *dcf_adapter =
repr->dcf_eth_dev->data->dev_private;
if (!dcf_adapter) {
PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n");
return NULL;
}
return &dcf_adapter->real_hw;
}
@ -124,6 +129,9 @@ ice_dcf_vf_repr_dev_info_get(struct rte_eth_dev *dev,
struct ice_dcf_vf_repr *repr = dev->data->dev_private;
struct ice_dcf_hw *dcf_hw = ice_dcf_vf_repr_hw(repr);
if (!dcf_hw)
return -EIO;
dev_info->device = dev->device;
dev_info->max_mac_addrs = 1;
dev_info->max_rx_queues = dcf_hw->vsi_res->num_queue_pairs;