From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 24E0D3784 for ; Fri, 20 Nov 2015 13:42:54 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 20 Nov 2015 04:42:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,322,1444719600"; d="scan'208";a="604012897" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by FMSMGA003.fm.intel.com with ESMTP; 20 Nov 2015 04:42:54 -0800 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.13]) by IRSMSX153.ger.corp.intel.com ([169.254.9.208]) with mapi id 14.03.0248.002; Fri, 20 Nov 2015 12:42:52 +0000 From: "Richardson, Bruce" To: "Mcnamara, John" , Mauricio Vasquez B , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit() Thread-Index: AQHRI4+N7OeqVaevJ0W/2ztRBrBeGJ6k2pBQ Date: Fri, 20 Nov 2015 12:42:52 +0000 Message-ID: <59AF69C657FD0841A61C55336867B5B0359866FE@IRSMSX103.ger.corp.intel.com> References: <1447885757-13038-1-git-send-email-mauricio.vasquezbernal@studenti.polito.it> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit() 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: Fri, 20 Nov 2015 12:42:55 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mcnamara, John > Sent: Friday, November 20, 2015 12:32 PM > To: Mauricio Vasquez B ; > dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] ring: Fix memory leakage in > rte_pmd_ring_devuninit() >=20 >=20 >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mauricio Vasquez > > B > > Sent: Wednesday, November 18, 2015 10:29 PM > > To: dev@dpdk.org > > Subject: [dpdk-dev] [PATCH] ring: Fix memory leakage in > > rte_pmd_ring_devuninit() > > > > When freeing the device, it is also necessary to free rx_queues and > > tx_queues > > > > Signed-off-by: Mauricio Vasquez B > > > > --- > > drivers/net/ring/rte_eth_ring.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/net/ring/rte_eth_ring.c > > b/drivers/net/ring/rte_eth_ring.c index 9a31bce..e091e4f 100644 > > --- a/drivers/net/ring/rte_eth_ring.c > > +++ b/drivers/net/ring/rte_eth_ring.c > > @@ -582,6 +582,9 @@ rte_pmd_ring_devuninit(const char *name) > > return -ENODEV; > > > > eth_dev_stop(eth_dev); > > + > > + 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); >=20 > Hi, >=20 > This should test for eth_dev->data before freeing the members. Like: >=20 > if (eth_dev->data) { > rte_free(eth_dev->data->rx_queues); > rte_free(eth_dev->data->tx_queues); > rte_free(eth_dev->data->dev_private); > } >=20 > Thanks, >=20 > John That was my thought initially too, but since this is an uninit routine, the= data field must already have been set up correctly by the init/creation fu= nction.=20 That being said, the check does no harm, so we might as well add it. /Bruce