From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E9CF45695 for ; Thu, 26 Feb 2015 09:44:05 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 26 Feb 2015 00:44:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,651,1418112000"; d="scan'208";a="690997740" Received: from unknown (HELO [10.217.248.122]) ([10.217.248.122]) by orsmga002.jf.intel.com with ESMTP; 26 Feb 2015 00:44:04 -0800 Message-ID: <54EEDCD2.20107@intel.com> Date: Thu, 26 Feb 2015 09:44:02 +0100 From: Pawel Wodkowski User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: dev@dpdk.org References: <1424932947-14750-1-git-send-email-changchun.ouyang@intel.com> In-Reply-To: <1424932947-14750-1-git-send-email-changchun.ouyang@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] 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: Thu, 26 Feb 2015 08:44:06 -0000 On 2015-02-26 07:42, 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 > --- > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 11 +++++++++-- > 1 file changed, 9 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..cf8f4fa 100644 > --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > @@ -694,6 +694,8 @@ error: > } > rte_free(*internals); > } > + if (qsockfd != -1) > + close(qsockfd); > return -1; > } > > @@ -822,16 +824,21 @@ rte_pmd_af_packet_devinit(const char *name, const char *params) > > ret = rte_kvargs_process(kvlist, ETH_AF_PACKET_IFACE_ARG, > &open_packet_iface, &sockfd); > - if (ret < 0) > + if (ret < 0) { > + rte_kvargs_free(kvlist); > return -1; > + } > } > > ret = rte_eth_from_packet(name, &sockfd, numa_node, kvlist); > close(sockfd); /* no longer needed */ > > - if (ret < 0) > + if (ret < 0) { > + rte_kvargs_free(kvlist); > return -1; > + } > > + rte_kvargs_free(kvlist); > return 0; > } > > This patch is correct but it would be good to rework it to have common error exit point like in rte_pmd_init_internals() function you changed. -- Pawel