From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1428; q=dns/txt; s=iport; t=1458255001; x=1459464601; h=from:to:cc:subject:date:message-id; bh=6tUZQZzjUJyhlFN0av+n1rc1rNrkn507GmcQ4Yt7VvY=; b=a5PDRDNa7WfB8wwa9a+046sLJStNbHx9fMOXk52DR9KRRpR1iLiD5PKh J8KeOqo/5f9FWteilF+QzXVFwCcWJ0LkvnDJWBzUcPtFnSrDQ+EibCz0z wr6qXes3JIsITRQ3I8p52RX2ZOwEXXMvLxAxW7ypc1VEwVLvzR1iHfAxM w=; X-IronPort-AV: E=Sophos;i="5.24,351,1454976000"; d="scan'208";a="250688696" Received: from alln-core-10.cisco.com ([173.36.13.132]) by alln-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 17 Mar 2016 22:50:00 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-10.cisco.com (8.14.5/8.14.5) with ESMTP id u2HMo0oW006806; Thu, 17 Mar 2016 22:50:00 GMT Received: by cisco.com (Postfix, from userid 392789) id E9F653FAAD77; Thu, 17 Mar 2016 15:49:59 -0700 (PDT) From: John Daley To: dev@dpdk.org Cc: Nelson Escobar Date: Thu, 17 Mar 2016 15:49:58 -0700 Message-Id: <1458254998-4336-1-git-send-email-johndale@cisco.com> X-Mailer: git-send-email 2.7.0 Subject: [dpdk-dev] [PATCH] enic: prevent segfaults when allocating too many TX or RX queues X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2016 22:50:01 -0000 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