[dpdk-dev,v3,3/4] virtio: return 1 to tell the upper layer we don't take over this device
Commit Message
v2 changes:
Remove unnecessary assignment of NULL to dev->data->mac_addrs
Ajust one comment's position
if virtio_resource_init fails, cleanup the resource and return 1 to
tell the upper layer we don't take over this device. -1 means error
which will cause DPDK to exit.
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
---
drivers/net/virtio/virtio_ethdev.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
@@ -1287,8 +1287,13 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
pci_dev = eth_dev->pci_dev;
- if (virtio_resource_init(pci_dev) < 0)
- return -1;
+ if (virtio_resource_init(pci_dev) < 0) {
+ rte_free(eth_dev->data->mac_addrs);
+ /* Return 1 to tell the upper layer we don't take over
+ * this device.
+ */
+ return 1;
+ }
hw->use_msix = virtio_has_msix(&pci_dev->addr);
hw->io_base = (uint32_t)(uintptr_t)pci_dev->mem_resource[0].addr;