From 5c11cefe0e2e03d5eef205dce0d6eb5c4fd340f9 Mon Sep 17 00:00:00 2001 From: Tetsuya Mukawa Date: Fri, 7 Aug 2015 18:21:26 +0900 Subject: [PATCH] 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 --- lib/librte_ether/rte_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.20.1