DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/virtio-user: fix recognize physical devices
@ 2017-04-21  2:28 Jianfeng Tan
  2017-04-26  1:26 ` Yuanhan Liu
  2017-04-28  4:49 ` Yuanhan Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Jianfeng Tan @ 2017-04-21  2:28 UTC (permalink / raw)
  To: dev; +Cc: yuanhan.liu, Jianfeng Tan

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>
---
 drivers/net/virtio/virtio_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index e6c57b3..3d712bd 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);
 	}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-28  4:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21  2:28 [dpdk-dev] [PATCH] net/virtio-user: fix recognize physical devices Jianfeng Tan
2017-04-26  1:26 ` Yuanhan Liu
2017-04-28  4:49 ` Yuanhan Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).