From patchwork Tue Aug 22 11:49:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie RongQiang X-Patchwork-Id: 27729 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 1B8437CE8; Wed, 23 Aug 2017 02:37:54 +0200 (CEST) Received: from zte.com.cn (mxhk.zte.com.cn [63.217.80.70]) by dpdk.org (Postfix) with ESMTP id B2E827CE5 for ; Wed, 23 Aug 2017 02:37:52 +0200 (CEST) X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170823083732 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 23 Aug 2017 00:37:32 -0000 Received: (from root@localhost) by mse01.zte.com.cn id v7N0bnek046622; Wed, 23 Aug 2017 08:37:49 +0800 (GMT-8) (envelope-from xie.rongqiang@zte.com.cn) Message-Id: <201708230037.v7N0bnek046622@mse01.zte.com.cn> Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v7MBo0g9095097; Tue, 22 Aug 2017 19:50:00 +0800 (GMT-8) (envelope-from xie.rongqiang@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.43.166.171]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017082219500460-517099 ; Tue, 22 Aug 2017 19:50:04 +0800 From: Rongqiang XIE To: wenzhuo.lu@intel.com Cc: dev@dpdk.org, Rongqiang XIE Date: Tue, 22 Aug 2017 19:49:21 +0800 X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-08-22 19:50:04, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2017-08-22 19:49:56, Serialize complete at 2017-08-22 19:49:56 X-MAIL: mse01.zte.com.cn v7N0bnek046622 X-MSS: AUDITRELEASE@mse01.zte.com.cn X-HQIP: 127.0.0.1 Subject: [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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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; + } (void)rte_memcpy(ðertype_filter_ptr->filter_info, ðertype_filter, sizeof(struct rte_eth_ethertype_filter)); @@ -2749,6 +2757,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[]) if (!ret) { syn_filter_ptr = rte_zmalloc("ixgbe_syn_filter", sizeof(struct ixgbe_eth_syn_filter_ele), 0); + if (!syn_filter_ptr) { + PMD_DRV_LOG(ERR, "failed to allocate memory"); + goto out; + } (void)rte_memcpy(&syn_filter_ptr->filter_info, &syn_filter, sizeof(struct rte_eth_syn_filter)); @@ -2809,6 +2821,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[]) if (!ret) { fdir_rule_ptr = rte_zmalloc("ixgbe_fdir_filter", sizeof(struct ixgbe_fdir_rule_ele), 0); + if (!fdir_rule_ptr) { + PMD_DRV_LOG(ERR, "failed to allocate memory"); + goto out; + } (void)rte_memcpy(&fdir_rule_ptr->filter_info, &fdir_rule, sizeof(struct ixgbe_fdir_rule)); @@ -2842,6 +2858,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[]) if (!ret) { l2_tn_filter_ptr = rte_zmalloc("ixgbe_l2_tn_filter", sizeof(struct ixgbe_eth_l2_tunnel_conf_ele), 0); + if (!l2_tn_filter_ptr) { + PMD_DRV_LOG(ERR, "failed to allocate memory"); + goto out; + } (void)rte_memcpy(&l2_tn_filter_ptr->filter_info, &l2_tn_filter, sizeof(struct rte_eth_l2_tunnel_conf));