[v4] net/i40e: fix i40evf device initialization
Checks
Commit Message
The i40evf driver is not initializing the eth_dev attribute which
can result in a nullptr dereference. Changes were modeled after the
iavf_dev_init() per suggestion from the mailing list[1] and
i40evf_init_vf().
[1] https://mails.dpdk.org/archives/dev/2021-August/217251.html
Rebased on v20.11.3.
Fixes: 4861cde46116 ("i40e: new poll mode driver")
Cc: stable@dpdk.org
Signed-off-by: Ben Magistro <koncept1@gmail.com>
---
drivers/net/i40e/i40e_ethdev_vf.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Mon, 2021-11-08 at 15:54 +0000, Ben Magistro wrote:
> The i40evf driver is not initializing the eth_dev attribute which
> can result in a nullptr dereference. Changes were modeled after the
> iavf_dev_init() per suggestion from the mailing list[1] and
> i40evf_init_vf().
>
> [1] https://mails.dpdk.org/archives/dev/2021-August/217251.html
>
> Rebased on v20.11.3.
>
> Fixes: 4861cde46116 ("i40e: new poll mode driver")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ben Magistro <koncept1@gmail.com>
> ---
Hi Ben,
Applied to 20.11.4 list, thanks!
Best Regards,
Xueming Li
@@ -1564,6 +1564,7 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
{
struct i40e_hw *hw
= I40E_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+ struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(eth_dev->data->dev_private);
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
PMD_INIT_FUNC_TRACE();
@@ -1594,12 +1595,17 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
hw->device_id = pci_dev->id.device_id;
hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
+ hw->bus.bus_id = pci_dev->addr.bus;
hw->bus.device = pci_dev->addr.devid;
hw->bus.func = pci_dev->addr.function;
hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
hw->adapter_stopped = 1;
hw->adapter_closed = 0;
+ vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(eth_dev->data->dev_private);
+ vf->dev_data = eth_dev->data;
+ hw->back = I40E_DEV_PRIVATE_TO_ADAPTER(vf);
+
if(i40evf_init_vf(eth_dev) != 0) {
PMD_INIT_LOG(ERR, "Init vf failed");
return -1;