examples/kni: check PCI info not NULL before reading
authorTomasz Duszynski <tdu@semihalf.com>
Mon, 16 Oct 2017 11:45:47 +0000 (13:45 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 24 Oct 2017 22:03:20 +0000 (00:03 +0200)
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 <tdu@semihalf.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
examples/kni/main.c

index edf3fb1..ddecc0e 100644 (file)
@@ -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;