From: Tetsuya Mukawa Date: Fri, 7 Aug 2015 09:21:26 +0000 (+0900) Subject: ethdev: fix illegal port access X-Git-Tag: spdx-start~8551 X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=5c11cefe0e2e03d5eef205dce0d6eb5c4fd340f9 ethdev: fix illegal port access To obtain detachable flag, pci_drv is accessed in rte_eth_dev_is_detachable(). But pci_drv is only valid if port is enabled. Not to cause illegal access, add rte_eth_dev_is_valid_port() before accessing. Signed-off-by: Tetsuya Mukawa Acked-by: Bernard Iremonger --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 5fe19061d2..6b2400cf02 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -505,7 +505,7 @@ rte_eth_dev_is_detachable(uint8_t port_id) { uint32_t drv_flags; - if (port_id >= RTE_MAX_ETHPORTS) { + if (!rte_eth_dev_is_valid_port(port_id)) { PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); return -EINVAL; }