[3/5] net/virtio: unmap device on initialization error
Checks
Commit Message
We should unmap the device when we failed to initialize the device.
Fixes: 6ba1f63b5ab0 ("virtio: support specification 1.0")
Cc: stable@dpdk.org
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
drivers/net/virtio/virtio_ethdev.c | 12 +++++++++---
drivers/net/virtio/virtio_pci.c | 1 +
2 files changed, 10 insertions(+), 3 deletions(-)
Comments
On 6/5/19 11:43 AM, Tiwei Bie wrote:
> We should unmap the device when we failed to initialize the device.
>
> Fixes: 6ba1f63b5ab0 ("virtio: support specification 1.0")
> Cc: stable@dpdk.org
>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
> drivers/net/virtio/virtio_ethdev.c | 12 +++++++++---
> drivers/net/virtio/virtio_pci.c | 1 +
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
@@ -1857,17 +1857,23 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
if (!hw->virtio_user_dev) {
ret = vtpci_init(RTE_ETH_DEV_TO_PCI(eth_dev), hw);
if (ret)
- goto out;
+ goto err_vtpci_init;
}
/* reset device and negotiate default features */
ret = virtio_init_device(eth_dev, VIRTIO_PMD_DEFAULT_GUEST_FEATURES);
if (ret < 0)
- goto out;
+ goto err_virtio_init;
return 0;
-out:
+err_virtio_init:
+ if (!hw->virtio_user_dev) {
+ rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));
+ if (!hw->modern)
+ rte_pci_ioport_unmap(VTPCI_IO(hw));
+ }
+err_vtpci_init:
rte_free(eth_dev->data->mac_addrs);
eth_dev->data->mac_addrs = NULL;
return ret;
@@ -678,6 +678,7 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
PMD_INIT_LOG(INFO, "trying with legacy virtio pci.");
if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
+ rte_pci_unmap_device(dev);
if (dev->kdrv == RTE_KDRV_UNKNOWN &&
(!dev->device.devargs ||
dev->device.devargs->bus !=