From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id A1EED2B8B for ; Thu, 3 Nov 2016 11:18:01 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 03 Nov 2016 03:18:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,438,1473145200"; d="scan'208";a="897232977" Received: from dpdk4.bj.intel.com ([172.16.182.178]) by orsmga003.jf.intel.com with ESMTP; 03 Nov 2016 03:17:58 -0700 From: Wei Dai To: dev@dpdk.org, mb@smartsharesystems.com Date: Thu, 3 Nov 2016 18:15:59 +0800 Message-Id: <1478168159-57529-1-git-send-email-wei.dai@intel.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] lpm: fix freeing memory 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, 03 Nov 2016 10:18:02 -0000 The memory pointed by lpm->rules_tbl should also be freed when memory malloc for tbl8 fails in rte_lpm_create_v1604( ). And the memory pointed by lpm->tbl8 should also be freed when the lpm object is freed in rte_lpm_free_v1604( ). Fixes: f1f7261838b3 ("lpm: add a new config structure for IPv4") Signed-off-by: Morten Brørup Signed-off-by: Wei Dai --- lib/librte_lpm/rte_lpm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index ec67765..8c15c4c 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -321,6 +321,7 @@ rte_lpm_create_v1604(const char *name, int socket_id, if (lpm->tbl8 == NULL) { RTE_LOG(ERR, LPM, "LPM tbl8 memory allocation failed\n"); + rte_free(lpm->rules_tbl); rte_free(lpm); lpm = NULL; rte_free(te); @@ -402,6 +403,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm) rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_free(lpm->tbl8); rte_free(lpm->rules_tbl); rte_free(lpm); rte_free(te); -- 2.7.4