ethdev: check queue stats mapping input arguments

With current implementation, we are not checking for queue_id range
and stat_idx range in stats mapping function. This patch will add
check for queue_id and stat_idx range.

Fixes: 5de201df89 ("ethdev: add stats per queue")

Signed-off-by: Kiran Kumar <kkokkilagadda@caviumnetworks.com>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
This commit is contained in:
Kiran Kumar 2018-07-11 14:11:59 +05:30 committed by Thomas Monjalon
parent beff6d8e8e
commit de9c75a548

View File

@ -2346,6 +2346,16 @@ set_queue_stats_mapping(uint16_t port_id, uint16_t queue_id, uint8_t stat_idx,
dev = &rte_eth_devices[port_id];
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
if (is_rx && (queue_id >= dev->data->nb_rx_queues))
return -EINVAL;
if (!is_rx && (queue_id >= dev->data->nb_tx_queues))
return -EINVAL;
if (stat_idx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)
return -EINVAL;
return (*dev->dev_ops->queue_stats_mapping_set)
(dev, queue_id, stat_idx, is_rx);
}