From: Kiran Kumar Date: Wed, 11 Jul 2018 08:41:59 +0000 (+0530) Subject: ethdev: check queue stats mapping input arguments X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=de9c75a5485832104d2a0c246544ba3a511802b4;p=dpdk.git 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: 5de201df892 ("ethdev: add stats per queue") Signed-off-by: Kiran Kumar Acked-by: Andrew Rybchenko --- diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 3d556a82f5..e262904497 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -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); }