From patchwork Thu Jan 16 16:38:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, TaoX" X-Patchwork-Id: 64756 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9F1E4A0352; Thu, 16 Jan 2020 09:01:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4203B1C066; Thu, 16 Jan 2020 09:01:11 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id E5CB01BFFE for ; Thu, 16 Jan 2020 09:01:09 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2020 00:01:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,325,1574150400"; d="scan'208";a="257212947" Received: from unknown (HELO localhost.localdomain) ([10.239.250.16]) by fmsmga001.fm.intel.com with ESMTP; 16 Jan 2020 00:01:06 -0800 From: taox.zhu@intel.com To: qiming.yang@intel.com, wenzhuo.lu@intel.com, simei.su@intel.com, yahui.cao@intel.com Cc: dev@dpdk.org, Tao Zhu Date: Thu, 16 Jan 2020 16:38:36 +0000 Message-Id: <20200116163836.15696-1-taox.zhu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] net/ice: fix flow fdir/switch memory leak. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Tao Zhu 1. Fix ice fdir and hash flow memory leak. 2. Fix the ice definition of LIST_FOR_EACH_ENTRY_SAFE not save tmp which cause list deletion incompletely. Fixes: 5f0978e9622 ("net/ice/base: add OS specific implementation") Fixes: f5cafa961fa ("net/ice: add flow director create and destroy") Fixes: 5ad3db8d4bd ("net/ice: enable advanced RSS") Signed-off-by: Tao Zhu Reviewed-by: Su, Simei Reviewed-by: Cao, Yahui Acked-by: Xiaolong Ye --- drivers/net/ice/base/ice_osdep.h | 17 +++++++++++++++-- drivers/net/ice/ice_fdir_filter.c | 12 +++++++----- drivers/net/ice/ice_hash.c | 12 ++++++------ 3 files changed, 28 insertions(+), 13 deletions(-) - File drivers/net/ice/base/ice_osdep.h need someone to review. - File drivers/net/ice/ice_fdir_filter.c reviewed by Yahui. - File drivers/net/ice/ice_hash.c reviewed by Simei. diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h index 27c1830..4b37406 100644 --- a/drivers/net/ice/base/ice_osdep.h +++ b/drivers/net/ice/base/ice_osdep.h @@ -343,6 +343,21 @@ static inline void list_add_tail(struct ice_list_entry *entry, member) : \ 0) +#define LIST_FOR_EACH_ENTRY_SAFE(pos, tmp, head, type, member) \ + for ((pos) = (head)->lh_first ? \ + container_of((head)->lh_first, struct type, member) : \ + 0, \ + (tmp) = (pos) == 0 ? 0 : ((pos)->member.next.le_next ? \ + container_of((pos)->member.next.le_next, struct type, \ + member) : \ + 0); \ + (pos); \ + (pos) = (tmp), \ + (tmp) = (pos) == 0 ? 0 : ((tmp)->member.next.le_next ? \ + container_of((pos)->member.next.le_next, struct type, \ + member) : \ + 0)) + #define LIST_REPLACE_INIT(list_head, head) do { \ (head)->lh_first = (list_head)->lh_first; \ INIT_LIST_HEAD(list_head); \ @@ -356,8 +371,6 @@ static inline void list_add_tail(struct ice_list_entry *entry, #define HLIST_DEL(entry) LIST_DEL(entry) #define HLIST_FOR_EACH_ENTRY(pos, head, type, member) \ LIST_FOR_EACH_ENTRY(pos, head, type, member) -#define LIST_FOR_EACH_ENTRY_SAFE(pos, tmp, head, type, member) \ - LIST_FOR_EACH_ENTRY(pos, head, type, member) #ifndef ICE_DBG_TRACE #define ICE_DBG_TRACE BIT_ULL(0) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index fa87074..c31a736 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -1938,23 +1938,25 @@ ret = ice_fdir_parse_pattern(ad, pattern, error, filter); if (ret) - return ret; + goto error; input_set = filter->input_set; if (!input_set || input_set & ~item->input_set_mask) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern, "Invalid input set"); - return -rte_errno; + ret = -rte_errno; + goto error; } ret = ice_fdir_parse_action(ad, actions, error, filter); if (ret) - return ret; + goto error; *meta = filter; - - return 0; +error: + rte_free(item); + return ret; } static struct ice_flow_parser ice_fdir_parser_os = { diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c index b145a3f..d891538 100644 --- a/drivers/net/ice/ice_hash.c +++ b/drivers/net/ice/ice_hash.c @@ -409,7 +409,7 @@ struct ice_hash_match_type ice_hash_type_list[] = { void **meta, struct rte_flow_error *error) { - int ret = 0; + int ret = -rte_errno; struct ice_pattern_match_item *pattern_match_item; struct rss_meta *rss_meta_ptr; @@ -425,11 +425,11 @@ struct ice_hash_match_type ice_hash_type_list[] = { pattern_match_item = ice_search_pattern_match_item(pattern, array, array_len, error); if (!pattern_match_item) - return -rte_errno; + goto error; ret = ice_hash_check_inset(pattern, error); if (ret) - return -rte_errno; + goto error; /* Save protocol header to rss_meta. */ *meta = rss_meta_ptr; @@ -438,12 +438,12 @@ struct ice_hash_match_type ice_hash_type_list[] = { /* Check rss action. */ ret = ice_hash_parse_action(pattern_match_item, actions, meta, error); +error: if (ret) - return -rte_errno; - + rte_free(rss_meta_ptr); rte_free(pattern_match_item); - return 0; + return ret; } static int