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 DC3B47D36 for ; Wed, 23 Aug 2017 12:36:39 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Aug 2017 03:36:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,416,1498546800"; d="scan'208";a="121841057" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.57]) ([10.237.220.57]) by orsmga004.jf.intel.com with ESMTP; 23 Aug 2017 03:36:37 -0700 To: Rongqiang XIE , wenzhuo.lu@intel.com Cc: dev@dpdk.org References: <201708230037.v7N0bnek046622@mse01.zte.com.cn> From: Ferruh Yigit Message-ID: <878e1a4e-1101-12d7-bad4-511f75f7e91b@intel.com> Date: Wed, 23 Aug 2017 11:36:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <201708230037.v7N0bnek046622@mse01.zte.com.cn> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net/ixgbe:fix some bugs about rte zmalloc memory may NULL 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: , X-List-Received-Date: Wed, 23 Aug 2017 10:36:40 -0000 On 8/22/2017 12:49 PM, Rongqiang XIE wrote: > In the function ixgbe_flow_create(), the value ntuple_filter_ptr, > ethertype_filter_ptr,syn_filter_ptr,fdir_rule_ptr and l2_tn_filter_ptr > use rte_zmalloc() malloc memory may return NULL,so, we should > add judge the return is NULL or success. > > Signed-off-by: Rongqiang XIE Reviewed-by: Ferruh Yigit > --- > drivers/net/ixgbe/ixgbe_flow.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c > index d679608..c8645f0 100644 > --- a/drivers/net/ixgbe/ixgbe_flow.c > +++ b/drivers/net/ixgbe/ixgbe_flow.c > @@ -2707,6 +2707,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[]) > if (!ret) { > ntuple_filter_ptr = rte_zmalloc("ixgbe_ntuple_filter", > sizeof(struct ixgbe_ntuple_filter_ele), 0); > + if (!ntuple_filter_ptr) { > + PMD_DRV_LOG(ERR, "failed to allocate memory"); > + goto out; > + } > (void)rte_memcpy(&ntuple_filter_ptr->filter_info, > &ntuple_filter, > sizeof(struct rte_eth_ntuple_filter)); > @@ -2729,6 +2733,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[]) > ethertype_filter_ptr = rte_zmalloc( > "ixgbe_ethertype_filter", > sizeof(struct ixgbe_ethertype_filter_ele), 0); > + if (!ethertype_filter_ptr) { > + PMD_DRV_LOG(ERR, "failed to allocate memory"); > + goto out; In out path, these variables should be freed which seems missing, would you mind another patch to fix this? > + } > (void)rte_memcpy(ðertype_filter_ptr->filter_info, > ðertype_filter, > sizeof(struct rte_eth_ethertype_filter)); <...>