From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 68D111F7 for ; Fri, 19 Dec 2014 16:47:47 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 19 Dec 2014 07:47:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,607,1413270000"; d="scan'208";a="650528067" Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by fmsmga002.fm.intel.com with ESMTP; 19 Dec 2014 07:47:19 -0800 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.244]) by IRSMSX108.ger.corp.intel.com ([169.254.11.71]) with mapi id 14.03.0195.001; Fri, 19 Dec 2014 15:47:18 +0000 From: "Jastrzebski, MichalX K" To: "Mrzyglod, DanielX T" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] af_packet: fix possible memory leak Thread-Index: AQHQG50SG3IgLv/gPE2p9kI36L4TG5yXDhqg Date: Fri, 19 Dec 2014 15:47:18 +0000 Message-ID: <60ABE07DBB3A454EB7FAD707B4BB1582138C1E9A@IRSMSX109.ger.corp.intel.com> References: <1419001296-8300-1-git-send-email-danielx.t.mrzyglod@intel.com> In-Reply-To: <1419001296-8300-1-git-send-email-danielx.t.mrzyglod@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] af_packet: fix possible memory leak 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, 19 Dec 2014 15:47:47 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Daniel Mrzyglod > Sent: Friday, December 19, 2014 4:02 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] af_packet: fix possible memory leak >=20 > In rte_pmd_init_internals, we are mapping memory but not released > if error occure it could produce memoryleak. > Add unmmap function to release memory. >=20 > Signed-off-by: Daniel Mrzyglod > --- > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 7 +++++++ > 1 file changed, 7 insertions(+) >=20 > diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > index 236749b..93e6b6b 100644 > --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > @@ -481,6 +481,11 @@ rte_pmd_init_internals(const char *name, > if (*internals =3D=3D NULL) > goto error; >=20 > + for (q =3D 0; q < nb_queues; q++) { > + (*internals)->rx_queue[q].map =3D MAP_FAILED; > + (*internals)->tx_queue[q].map =3D MAP_FAILED; > + } > + > req =3D &((*internals)->req); >=20 > req->tp_block_size =3D blocksize; > @@ -682,6 +687,8 @@ error: > rte_free(pci_dev); > if (*internals) { > for (q =3D 0; q < nb_queues; q++) { > + munmap((*internals)->rx_queue[q].map, > + 2 * req- > >tp_block_size * req->tp_block_nr); > if ((*internals)->rx_queue[q].rd) > rte_free((*internals)->rx_queue[q].rd); > if ((*internals)->tx_queue[q].rd) > -- > 2.1.0 Acked-by: Michal Jastrzebski