ethdev: fix illegal port access
authorTetsuya Mukawa <mukawa@igel.co.jp>
Fri, 7 Aug 2015 09:21:26 +0000 (18:21 +0900)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Sun, 9 Aug 2015 17:48:12 +0000 (19:48 +0200)
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 <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
lib/librte_ether/rte_ethdev.c

index 5fe1906..6b2400c 100644 (file)
@@ -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;
        }