net/ice: fix crash on representor port closing
[dpdk.git] / drivers / net / ice / ice_dcf_vf_representor.c
index 970461f..b547c42 100644 (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;