net/iavf: fix resource leak on probing failure
During the port probe process, there are two abnormal branches that did
not release the previously requested memory, resulting in leakage. The
patch adds an iavf_uninit_vf function, which corresponds to the
iavf_init_vf function.
Fixes: ff2d0c345c
("net/iavf: support generic flow API")
Cc: stable@dpdk.org
Signed-off-by: Qiming Chen <chenqiming_huawei@163.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
This commit is contained in:
parent
c9c45beb1b
commit
45570d7e44
@ -2176,6 +2176,30 @@ iavf_init_vf(struct rte_eth_dev *dev)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
iavf_uninit_vf(struct rte_eth_dev *dev)
|
||||
{
|
||||
struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
|
||||
|
||||
iavf_shutdown_adminq(hw);
|
||||
|
||||
rte_free(vf->vf_res);
|
||||
vf->vsi_res = NULL;
|
||||
vf->vf_res = NULL;
|
||||
|
||||
rte_free(vf->aq_resp);
|
||||
vf->aq_resp = NULL;
|
||||
|
||||
rte_free(vf->qos_cap);
|
||||
vf->qos_cap = NULL;
|
||||
|
||||
rte_free(vf->rss_lut);
|
||||
vf->rss_lut = NULL;
|
||||
rte_free(vf->rss_key);
|
||||
vf->rss_key = NULL;
|
||||
}
|
||||
|
||||
/* Enable default admin queue interrupt setting */
|
||||
static inline void
|
||||
iavf_enable_irq0(struct iavf_hw *hw)
|
||||
@ -2304,7 +2328,8 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
|
||||
PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to"
|
||||
" store MAC addresses",
|
||||
RTE_ETHER_ADDR_LEN * IAVF_NUM_MACADDR_MAX);
|
||||
return -ENOMEM;
|
||||
ret = -ENOMEM;
|
||||
goto init_vf_err;
|
||||
}
|
||||
/* If the MAC address is not configured by host,
|
||||
* generate a random one.
|
||||
@ -2329,12 +2354,21 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
|
||||
ret = iavf_flow_init(adapter);
|
||||
if (ret) {
|
||||
PMD_INIT_LOG(ERR, "Failed to initialize flow");
|
||||
return ret;
|
||||
goto flow_init_err;
|
||||
}
|
||||
|
||||
iavf_default_rss_disable(adapter);
|
||||
|
||||
return 0;
|
||||
|
||||
flow_init_err:
|
||||
rte_free(eth_dev->data->mac_addrs);
|
||||
eth_dev->data->mac_addrs = NULL;
|
||||
|
||||
init_vf_err:
|
||||
iavf_uninit_vf(eth_dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user