From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from antispam.polito.it (fm1nodo1.polito.it [130.192.180.11]) by dpdk.org (Postfix) with ESMTP id 2E71C1023 for ; Wed, 2 Nov 2016 14:46:20 +0100 (CET) Received: from polito.it (frontmail1.polito.it [130.192.180.41]) by antispam.polito.it with ESMTP id uA2DkJct003102-uA2DkJcx003102 (version=TLSv1.0 cipher=DHE-RSA-AES256-SHA bits=256 verify=CAFAIL); Wed, 2 Nov 2016 14:46:19 +0100 Received: from [190.9.209.39] (account d040768@polito.it HELO localhost.localdomain) by polito.it (CommuniGate Pro SMTP 6.1.9) with ESMTPSA id 112231970; Wed, 02 Nov 2016 14:46:19 +0100 From: Mauricio Vasquez B To: bruce.richardson@intel.com Date: Wed, 2 Nov 2016 08:46:09 -0500 Message-Id: <1478094369-3943-1-git-send-email-mauricio.vasquez@polito.it> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1478030140-7127-1-git-send-email-mauricio.vasquez@polito.it> References: <1478030140-7127-1-git-send-email-mauricio.vasquez@polito.it> X-FEAS-SYSTEM-WL: 130.192.180.41 Cc: dev@dpdk.org, ferruh.yigit@intel.com Subject: [dpdk-dev] [PATCH v3] net/ring: remove unnecessary NULL check 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: Wed, 02 Nov 2016 13:46:20 -0000 Coverity detected this as an issue because internals->data will never be NULL, then the check is not necessary. Fixes: d082c0395bf6 ("ring: fix memory leak when detaching") Coverity issue: 137873 Signed-off-by: Mauricio Vasquez B --- drivers/net/ring/rte_eth_ring.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 6d2a8c1..c1767c4 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -599,24 +599,22 @@ rte_pmd_ring_remove(const char *name) eth_dev_stop(eth_dev); - if (eth_dev->data) { - internals = eth_dev->data->dev_private; - if (internals->action == DEV_CREATE) { - /* - * it is only necessary to delete the rings in rx_queues because - * they are the same used in tx_queues - */ - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - r = eth_dev->data->rx_queues[i]; - rte_ring_free(r->rng); - } + internals = eth_dev->data->dev_private; + if (internals->action == DEV_CREATE) { + /* + * it is only necessary to delete the rings in rx_queues because + * they are the same used in tx_queues + */ + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { + r = eth_dev->data->rx_queues[i]; + rte_ring_free(r->rng); } - - rte_free(eth_dev->data->rx_queues); - rte_free(eth_dev->data->tx_queues); - rte_free(eth_dev->data->dev_private); } + rte_free(eth_dev->data->rx_queues); + rte_free(eth_dev->data->tx_queues); + rte_free(eth_dev->data->dev_private); + rte_free(eth_dev->data); rte_eth_dev_release_port(eth_dev); -- 1.9.1