From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Daley Subject: [PATCH] enic: prevent segfaults when allocating too many TX or RX queues Date: Thu, 17 Mar 2016 15:49:58 -0700 Message-ID: <1458254998-4336-1-git-send-email-johndale@cisco.com> Cc: Nelson Escobar To: dev@dpdk.org Return-path: Received: from alln-iport-6.cisco.com (alln-iport-6.cisco.com [173.37.142.93]) by dpdk.org (Postfix) with ESMTP id 14D1F2BA8 for ; Thu, 17 Mar 2016 23:50:00 +0100 (CET) List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Nelson Escobar Add checks to make sure we don't try to allocate more tx or rx queues than we support. Signed-off-by: Nelson Escobar Reviewed-by: John Daley --- drivers/net/enic/enic_ethdev.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 6f2ada5..6c3c734 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -174,6 +174,13 @@ static int enicpmd_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, struct enic *enic = pmd_priv(eth_dev); ENICPMD_FUNC_TRACE(); + if (queue_idx >= ENIC_WQ_MAX) { + dev_err(enic, + "Max number of TX queues exceeded. Max is %d\n", + ENIC_WQ_MAX); + return -EINVAL; + } + eth_dev->data->tx_queues[queue_idx] = (void *)&enic->wq[queue_idx]; ret = enic_alloc_wq(enic, queue_idx, socket_id, nb_desc); @@ -262,6 +269,13 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, struct enic *enic = pmd_priv(eth_dev); ENICPMD_FUNC_TRACE(); + if (queue_idx >= ENIC_RQ_MAX) { + dev_err(enic, + "Max number of RX queues exceeded. Max is %d\n", + ENIC_RQ_MAX); + return -EINVAL; + } + eth_dev->data->rx_queues[queue_idx] = (void *)&enic->rq[queue_idx]; ret = enic_alloc_rq(enic, queue_idx, socket_id, mp, nb_desc); -- 2.7.0