summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJianfeng Tan <jianfeng.tan@intel.com>2017-04-21 02:28:09 +0000
committerYuanhan Liu <yuanhan.liu@linux.intel.com>2017-04-28 07:01:22 +0200
commit2c2201fb0745d3d46be324fa86989224ea2f0d83 (patch)
tree6ccb206b44f5f30e309cc706a6f27a4f4ee6e1ca
parent58d9fe4000ee918b1d7f0260191349dd2f13ef02 (diff)
downloaddpdk-stable-2c2201fb0745d3d46be324fa86989224ea2f0d83.zip
dpdk-stable-2c2201fb0745d3d46be324fa86989224ea2f0d83.tar.gz
dpdk-stable-2c2201fb0745d3d46be324fa86989224ea2f0d83.tar.xz
net/virtio-user: fix device type check
Segfault happens when using virtio-user after commit 7f0a669e7b04 ("ethdev: add allocation helper for virtual drivers"). It's due to we use ethdev->device to recognize physical devices, but after above commit, this field is also filled for virtual devices. Then we obtain the wrong pci_dev pointer and accessing its field when copying pci info results in segfault. To fix it, we use hw->virtio_user_dev to differentiate physical devices from virtual devices. Fixes: 6a7c0dfcdf40 ("net/virtio: do not depend on PCI device of ethdev") Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
-rw-r--r--drivers/net/virtio/virtio_ethdev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index cd87c0e..73e5da8 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1348,7 +1348,7 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
if (virtio_negotiate_features(hw, req_features) < 0)
return -1;
- if (eth_dev->device) {
+ if (!hw->virtio_user_dev) {
pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
rte_eth_copy_pci_info(eth_dev, pci_dev);
}