From: Yuanhan Liu Date: Sun, 22 Jan 2017 08:47:00 +0000 (+0800) Subject: net/virtio: fix crash when number of virtio devices > 1 X-Git-Tag: spdx-start~4636 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7687312571c90c3e5f93a4eb29c7a45c828d1f79;p=dpdk.git net/virtio: fix crash when number of virtio devices > 1 The vtpci_ops assignment needs the 'hw->port_id' as an input parameter. That said, we should set 'hw->port_id' firstly, then do the vtpci_ops assignment, while the code does reversely. That would result to a crash when more than one virtio devices are used, because we keep assigning proper vtpci_ops to virtio_hw_internal[0]->vtpci_ops, leaving the pointer for other ports being NULL. Reverse the order fixes this issue. Fixes: 9470427c88e1 ("net/virtio: do not store PCI device pointer at shared memory") Cc: stable@dpdk.org Reported-by: Lei Yao Signed-off-by: Yuanhan Liu Reviewed-by: Maxime Coquelin --- diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 1d51942903..68dde08548 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1515,6 +1515,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) return -ENOMEM; } + hw->port_id = eth_dev->data->port_id; /* For virtio_user case the hw->virtio_user_dev is populated by * virtio_user_eth_dev_alloc() before eth_virtio_dev_init() is called. */ @@ -1525,7 +1526,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) return ret; } - hw->port_id = eth_dev->data->port_id; eth_dev->data->dev_flags = dev_flags; /* reset device and negotiate default features */