From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 48D67A0471 for ; Thu, 18 Jul 2019 05:39:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AC87E1BE01; Thu, 18 Jul 2019 05:37:33 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id C2D171BDF2; Thu, 18 Jul 2019 05:37:05 +0200 (CEST) Received: from nis-sj1-27.broadcom.com (nis-sj1-27.lvn.broadcom.net [10.75.144.136]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 6029D30C38E; Wed, 17 Jul 2019 20:37:03 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 6029D30C38E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1563421023; bh=JWmL64i9alkPXCYUH6wYtRlJUwZ1ZVcuQqnpgBhvvaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYUiYQArNfKqoD1FIo2EAdQ9fHmPowlv5pidY2wK3YC76Di3OaYgzuJarZszPawER 41JC2mNXwIUHaAqVReRFhjS8is7T4h4dIqDKDbL/OHyfx0lr/WOYrUoY+k27ckmfov 1U8aukc9c1/eSE0V/u47dHvQEWaqu4p31nSWYNlw= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.122.43.105]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id CC0B2AC0761; Wed, 17 Jul 2019 20:37:02 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Lance Richardson , stable@dpdk.org, Kalesh Anakkur Purayil Date: Thu, 18 Jul 2019 09:06:13 +0530 Message-Id: <20190718033616.37605-20-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190718033616.37605-1-ajit.khaparde@broadcom.com> References: <20190718033616.37605-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 19/22] net/bnxt: avoid overrun in get statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Lance Richardson Avoid overrun in rte_eth_stats struct when the number of tx/rx rings in use is greater than RTE_ETHDEV_QUEUE_STAT_CNTRS. Fixes: 57d5e5bc86e4 ("net/bnxt: add statistics") Cc: stable@dpdk.org Reviewed-by: Kalesh Anakkur Purayil Reviewed-by: Ajit Khaparde Signed-off-by: Lance Richardson --- drivers/net/bnxt/bnxt_stats.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 3cd5144ec..4e74f8a27 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -351,6 +351,7 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, int rc = 0; unsigned int i; struct bnxt *bp = eth_dev->data->dev_private; + unsigned int num_q_stats; memset(bnxt_stats, 0, sizeof(*bnxt_stats)); if (!(bp->flags & BNXT_FLAG_INIT_DONE)) { @@ -358,7 +359,10 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, return -1; } - for (i = 0; i < bp->rx_cp_nr_rings; i++) { + num_q_stats = RTE_MIN(bp->rx_cp_nr_rings, + (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS); + + for (i = 0; i < num_q_stats; i++) { struct bnxt_rx_queue *rxq = bp->rx_queues[i]; struct bnxt_cp_ring_info *cpr = rxq->cp_ring; @@ -370,7 +374,10 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, rte_atomic64_read(&rxq->rx_mbuf_alloc_fail); } - for (i = 0; i < bp->tx_cp_nr_rings; i++) { + num_q_stats = RTE_MIN(bp->tx_cp_nr_rings, + (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS); + + for (i = 0; i < num_q_stats; i++) { struct bnxt_tx_queue *txq = bp->tx_queues[i]; struct bnxt_cp_ring_info *cpr = txq->cp_ring; -- 2.20.1 (Apple Git-117)