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 <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
This commit is contained in:
Tetsuya Mukawa 2015-08-07 18:21:26 +09:00 committed by Thomas Monjalon
parent cd10c42eb5
commit 5c11cefe0e

View 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;
}