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 B6F3D5947 for ; Mon, 9 Mar 2015 09:48:13 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 09 Mar 2015 01:48:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,366,1422950400"; d="scan'208";a="464511287" Received: from pgsmsx102.gar.corp.intel.com ([10.221.44.80]) by FMSMGA003.fm.intel.com with ESMTP; 09 Mar 2015 01:41:34 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by PGSMSX102.gar.corp.intel.com (10.221.44.80) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 9 Mar 2015 16:47:55 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.62]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.161]) with mapi id 14.03.0195.001; Mon, 9 Mar 2015 16:47:53 +0800 From: "Ouyang, Changchun" To: "Qiu, Michael" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4] af_packet: Fix some klocwork errors Thread-Index: AQHQWhwBSTIin+G8GEyT4xWtgMwyZp0T0v0w Date: Mon, 9 Mar 2015 08:47:53 +0000 Message-ID: References: <1425086874-6238-1-git-send-email-changchun.ouyang@intel.com> <1425872941-26481-1-git-send-email-changchun.ouyang@intel.com> <533710CFB86FA344BFBF2D6802E60286CF065F@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286CF065F@SHSMSX101.ccr.corp.intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4] af_packet: Fix some klocwork errors 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: Mon, 09 Mar 2015 08:48:14 -0000 Hi Michael, > -----Original Message----- > From: Qiu, Michael > Sent: Monday, March 9, 2015 2:39 PM > To: Ouyang, Changchun; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v4] af_packet: Fix some klocwork errors >=20 > On 3/9/2015 11:49 AM, Ouyang Changchun wrote: > > Fix possible memory leak issue: free kvlist before return; Fix > > possible resource lost issue: close qssockfd before return; > > > > Signed-off-by: Changchun Ouyang > > --- > > Change in v4: > > - Check sockfd in internals->rx_queue against 0. > > > > Change in v3: > > - Also close sockets for all queues. > > > > Change in v2: > > - Make the error exit point a common path. > > > > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 14 ++++++++++++-- > > 1 file changed, 12 insertions(+), 2 deletions(-) > > > > 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 80e9bdf..acdf408 100644 > > --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > > +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > > @@ -691,9 +691,14 @@ error: > > rte_free((*internals)->rx_queue[q].rd); > > if ((*internals)->tx_queue[q].rd) > > rte_free((*internals)->tx_queue[q].rd); > > + if (((*internals)->rx_queue[q].sockfd !=3D 0) && > > + ((*internals)->rx_queue[q].sockfd !=3D > qsockfd)) > > + close((*internals)->rx_queue[q].sockfd); > > } > > rte_free(*internals); > > } > > + if (qsockfd !=3D -1) >=20 > Hi, Ouyang >=20 > qsockfd was first initialized: > for (q =3D 0; q < nb_queues; q++) { > /* Open an AF_PACKET socket for this queue... */ > qsockfd =3D socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL))= ; >=20 > What will happen if gets an error before here, is there any issue? I thin= k > better to initialize it when declare it. > Make sense, will make next version to resolve it Thanks Changchun =20