diff options
author | Deepak S <deepak.s@linux.intel.com> | 2018-12-06 02:59:38 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-12-06 02:59:38 +0000 |
commit | 47123bfc1b3c0d0b01884aebbce1a3e09ad7ddb0 (patch) | |
tree | aaa4770051c1c1163f9dba277f8199a0f53c33ef | |
parent | 8dd272c5f94e4d7faa8d23d4943137f3779e2c05 (diff) | |
parent | 2a16001e311b414bdadd42d048a12e6995a0e20e (diff) |
Merge "Fix potential crash when getting device info"
-rw-r--r-- | VNFs/DPPD-PROX/prox_port_cfg.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/VNFs/DPPD-PROX/prox_port_cfg.c b/VNFs/DPPD-PROX/prox_port_cfg.c index 661b6716..5c5ca58f 100644 --- a/VNFs/DPPD-PROX/prox_port_cfg.c +++ b/VNFs/DPPD-PROX/prox_port_cfg.c @@ -224,16 +224,6 @@ void init_rte_dev(int use_dummy_devices) port_cfg->max_rx_pkt_len = dev_info.max_rx_pktlen; port_cfg->min_rx_bufsize = dev_info.min_rx_bufsize; -#if RTE_VERSION < RTE_VERSION_NUM(18,5,0,0) - pci_dev = dev_info.pci_dev; -#else - pci_dev = RTE_DEV_TO_PCI(dev_info.device); -#endif - if (!pci_dev) - continue; - - snprintf(port_cfg->pci_addr, sizeof(port_cfg->pci_addr), - "%04x:%02x:%02x.%1x", pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); strncpy(port_cfg->driver_name, dev_info.driver_name, sizeof(port_cfg->driver_name)); plog_info("\tPort %u : driver='%s' tx_queues=%d rx_queues=%d\n", port_id, !strcmp(port_cfg->driver_name, "")? "null" : port_cfg->driver_name, port_cfg->max_txq, port_cfg->max_rxq); @@ -249,6 +239,18 @@ void init_rte_dev(int use_dummy_devices) *ptr = '\x0'; } +#if RTE_VERSION < RTE_VERSION_NUM(18,5,0,0) + pci_dev = dev_info.pci_dev; +#else + if (!dev_info.device) + continue; + pci_dev = RTE_DEV_TO_PCI(dev_info.device); +#endif + if (!pci_dev) + continue; + + snprintf(port_cfg->pci_addr, sizeof(port_cfg->pci_addr), + "%04x:%02x:%02x.%1x", pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); /* Try to find the device's numa node */ char buf[1024]; snprintf(buf, sizeof(buf), "/sys/bus/pci/devices/%s/numa_node", port_cfg->pci_addr); |