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 11C91A2EDB for ; Wed, 2 Oct 2019 07:56:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AFF4E1BEEC; Wed, 2 Oct 2019 07:54:58 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (unknown [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 8F9A54C9D; Wed, 2 Oct 2019 07:54:31 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 9F3D330D4F2; Tue, 1 Oct 2019 22:53:19 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 9F3D330D4F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1569995599; bh=2vpB3r+t6/bDkz8UXC2zSQYa7PqgX74lrTumH+Ax0oM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=laIAVhjDDPitT8+pe8o8kDcU98nygPG3aPx1Rslk9b3HniVlEw3oUIWn/8zBY0zcA hLucDri7CMnxs54tLlv953lAvfYWKZQCymwqN2dXTbJmSbWmPLf9OwiHUugm1qdQW1 bNuUq9Pmy8NDMh68Yoa02PqeWBtQSQjjNaUPMMHA= Received: from localhost.localdomain (unknown [10.230.30.225]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 07844140090; Tue, 1 Oct 2019 22:54:30 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Kalesh AP , stable@dpdk.org, Santoshkumar Karanappa Rastapur Date: Tue, 1 Oct 2019 22:54:18 -0700 Message-Id: <20191002055423.99659-13-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20191002055423.99659-1-ajit.khaparde@broadcom.com> References: <20191002055423.99659-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 12/17] net/bnxt: fix accessing variable before null check 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: Kalesh AP Check input argument "rxq" in bnxt_rx_queue_release_mbufs(), to be sure variable is not NULL before accessing it. Fixes: 9b63c6fd70e3 ("net/bnxt: support Rx/Tx queue start/stop") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Santoshkumar Karanappa Rastapur Reviewed-by: Ajit Khaparde Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_rxq.c | 53 +++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index 4b506f8653..dac8ccb167 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -207,39 +207,40 @@ void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq) struct bnxt_tpa_info *tpa_info; uint16_t i; + if (!rxq) + return; + rte_spinlock_lock(&rxq->lock); - if (rxq) { - sw_ring = rxq->rx_ring->rx_buf_ring; - if (sw_ring) { - for (i = 0; - i < rxq->rx_ring->rx_ring_struct->ring_size; i++) { - if (sw_ring[i].mbuf) { - rte_pktmbuf_free_seg(sw_ring[i].mbuf); - sw_ring[i].mbuf = NULL; - } + sw_ring = rxq->rx_ring->rx_buf_ring; + if (sw_ring) { + for (i = 0; + i < rxq->rx_ring->rx_ring_struct->ring_size; i++) { + if (sw_ring[i].mbuf) { + rte_pktmbuf_free_seg(sw_ring[i].mbuf); + sw_ring[i].mbuf = NULL; } } - /* Free up mbufs in Agg ring */ - sw_ring = rxq->rx_ring->ag_buf_ring; - if (sw_ring) { - for (i = 0; - i < rxq->rx_ring->ag_ring_struct->ring_size; i++) { - if (sw_ring[i].mbuf) { - rte_pktmbuf_free_seg(sw_ring[i].mbuf); - sw_ring[i].mbuf = NULL; - } + } + /* Free up mbufs in Agg ring */ + sw_ring = rxq->rx_ring->ag_buf_ring; + if (sw_ring) { + for (i = 0; + i < rxq->rx_ring->ag_ring_struct->ring_size; i++) { + if (sw_ring[i].mbuf) { + rte_pktmbuf_free_seg(sw_ring[i].mbuf); + sw_ring[i].mbuf = NULL; } } + } - /* Free up mbufs in TPA */ - tpa_info = rxq->rx_ring->tpa_info; - if (tpa_info) { - for (i = 0; i < BNXT_TPA_MAX; i++) { - if (tpa_info[i].mbuf) { - rte_pktmbuf_free_seg(tpa_info[i].mbuf); - tpa_info[i].mbuf = NULL; - } + /* Free up mbufs in TPA */ + tpa_info = rxq->rx_ring->tpa_info; + if (tpa_info) { + for (i = 0; i < BNXT_TPA_MAX; i++) { + if (tpa_info[i].mbuf) { + rte_pktmbuf_free_seg(tpa_info[i].mbuf); + tpa_info[i].mbuf = NULL; } } } -- 2.20.1 (Apple Git-117)