From 1e02d735c1446705592ca8d89b4b500f9492a8ef Mon Sep 17 00:00:00 2001 From: Tomasz Duszynski Date: Mon, 16 Oct 2017 13:45:47 +0200 Subject: [PATCH] examples/kni: check PCI info not NULL before reading Since virtual devices, i.e mrvl net pmd, do not touch pci_dev dereferencing it will cause segmentation fault as by default it's set to NULL in rte_eth_dev_info_get(). Signed-off-by: Tomasz Duszynski Acked-by: Ferruh Yigit --- examples/kni/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/kni/main.c b/examples/kni/main.c index edf3fb1b0d..ddecc0ee4a 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -805,8 +805,11 @@ kni_alloc(uint16_t port_id) memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(port_id, &dev_info); - conf.addr = dev_info.pci_dev->addr; - conf.id = dev_info.pci_dev->id; + + if (dev_info.pci_dev) { + conf.addr = dev_info.pci_dev->addr; + conf.id = dev_info.pci_dev->id; + } memset(&ops, 0, sizeof(ops)); ops.port_id = port_id; -- 2.20.1