net/virtio: fix crash when number of virtio devices > 1
authorYuanhan Liu <yuanhan.liu@linux.intel.com>
Sun, 22 Jan 2017 08:47:00 +0000 (16:47 +0800)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Sat, 28 Jan 2017 13:25:40 +0000 (14:25 +0100)
commit7687312571c90c3e5f93a4eb29c7a45c828d1f79
treea37a6782cdf2ae38a5f3e8fb3fbf45c969a82ce2
parentb8b992e93f387b0d0dda00b9feb6adb05ffe081c
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 <lei.a.yao@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_ethdev.c