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 6503F29CA for ; Wed, 2 Nov 2016 13:49:06 +0100 (CET) Received: from polito.it (frontmail1.polito.it [130.192.180.41]) by antispam.polito.it with ESMTP id uA2Cn5RB027101-uA2Cn5RF027101 (version=TLSv1.0 cipher=DHE-RSA-AES256-SHA bits=256 verify=CAFAIL); Wed, 2 Nov 2016 13:49:05 +0100 Received: from [195.37.186.62] (account d003306@polito.it HELO [10.200.175.113]) by polito.it (CommuniGate Pro SMTP 6.1.9) with ESMTPSA id 112228681; Wed, 02 Nov 2016 13:49:05 +0100 To: Ferruh Yigit , Mauricio Vasquez B , bruce.richardson@intel.com References: <1477972113-2600-1-git-send-email-mauricio.vasquez@polito.it> <1478030140-7127-1-git-send-email-mauricio.vasquez@polito.it> <6c7a2a77-7370-3550-7aad-d98327f033ba@intel.com> From: Fulvio Risso Message-ID: <7a81d33e-4b91-7dca-e6e4-f009d295bebf@polito.it> Date: Wed, 2 Nov 2016 13:49:03 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <6c7a2a77-7370-3550-7aad-d98327f033ba@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-FEAS-SYSTEM-WL: 130.192.180.41 Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v2] 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 12:49:06 -0000 Dear Ferruh, Maybe I'm wrong, but I cannot see your point. The code is absolutely the same, only the following line if (eth_dev->data) { is actually removed. fulvio On 02/11/2016 12:38, Ferruh Yigit wrote: > Hi Mauricio, > > On 11/1/2016 7:55 PM, Mauricio Vasquez B wrote: >> 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 | 20 +++++++++----------- >> 1 file changed, 9 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c >> index 6d2a8c1..5ca00ed 100644 >> --- a/drivers/net/ring/rte_eth_ring.c >> +++ b/drivers/net/ring/rte_eth_ring.c >> @@ -599,17 +599,15 @@ 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); > > This patch not only removes the NULL check but also changes the logic. > after patch rx_queues, tx_queues and dev_private only freed if action is > DEV_CREATE which is wrong. > >> >