From: Tomasz Duszynski Date: Mon, 16 Oct 2017 11:45:47 +0000 (+0200) Subject: examples/kni: check PCI info not NULL before reading X-Git-Tag: spdx-start~1230 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1e02d735c1446705592ca8d89b4b500f9492a8ef;p=dpdk.git 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 --- 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;