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 8C76D5681 for ; Fri, 27 Feb 2015 01:49:24 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 26 Feb 2015 16:49:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,656,1418112000"; d="scan'208";a="691410109" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 26 Feb 2015 16:49:22 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t1R0nJoK027338; Fri, 27 Feb 2015 08:49:19 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t1R0nGta025983; Fri, 27 Feb 2015 08:49:18 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t1R0nGRp025973; Fri, 27 Feb 2015 08:49:16 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Fri, 27 Feb 2015 08:49:13 +0800 Message-Id: <1424998153-22718-1-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1424932947-14750-1-git-send-email-changchun.ouyang@intel.com> References: <1424932947-14750-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH v2] 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: Fri, 27 Feb 2015 00:49:25 -0000 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 v2: - Make the error exit point a common path. 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..c675724 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; } @@ -823,16 +825,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) - return -1; + goto error; } ret = rte_eth_from_packet(name, &sockfd, numa_node, kvlist); close(sockfd); /* no longer needed */ if (ret < 0) - return -1; + goto error; + rte_kvargs_free(kvlist); return 0; + +error: + rte_kvargs_free(kvlist); + return -1; } static struct rte_driver pmd_af_packet_drv = { -- 1.8.4.2