From patchwork Fri Sep 11 13:19:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 77413 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 22084A04B7; Fri, 11 Sep 2020 15:21:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6CA671C214; Fri, 11 Sep 2020 15:16:53 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 440061C1C9 for ; Fri, 11 Sep 2020 15:16:39 +0200 (CEST) IronPort-SDR: KKJURPCBqFKdPHrEK86PcftSWmbJPRWG4v/d8xCaEDGdutdUw3FjidmqPKNQWb74pYWJS+hj8o FGaGHfW7zL7w== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146482332" X-IronPort-AV: E=Sophos;i="5.76,415,1592895600"; d="scan'208";a="146482332" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 06:16:38 -0700 IronPort-SDR: +PMF6jRmO5dbdLh2vzyA5+UQHRvbTaJRoIZUFMO1vO629IUMZ9aN9bnLnr8DGYzw7yqzVFhkim pDMcY7x+D30Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,415,1592895600"; d="scan'208";a="342296684" Received: from dpdk51.sh.intel.com ([10.67.111.82]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2020 06:16:37 -0700 From: Qi Zhang To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Qi Zhang , Tony Nguyen Date: Fri, 11 Sep 2020 21:19:40 +0800 Message-Id: <20200911131954.15999-27-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20200911131954.15999-1-qi.z.zhang@intel.com> References: <20200907112826.48493-1-qi.z.zhang@intel.com> <20200911131954.15999-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2 26/40] net/ice/base: add check for failed acts allocation 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" There is no check for failed allocation of 'acts'. Add a check and return if memory was not successfully allocated. Also, as all 'goto out' occur after this check there is no need to perform a check for 'acts' as we will have returned if it is not set. Signed-off-by: Tony Nguyen Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/base/ice_flow.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c index 65ab2394f..d96bf169f 100644 --- a/drivers/net/ice/base/ice_flow.c +++ b/drivers/net/ice/base/ice_flow.c @@ -1712,8 +1712,8 @@ ice_flow_acl_is_prof_in_use(struct ice_hw *hw, struct ice_flow_prof *prof, buf->pf_scenario_num[6] == ICE_ACL_INVALID_SCEN && buf->pf_scenario_num[7] == ICE_ACL_INVALID_SCEN) return ICE_SUCCESS; - else - return ICE_ERR_IN_USE; + + return ICE_ERR_IN_USE; } /** @@ -2861,7 +2861,6 @@ ice_flow_acl_add_scen_entry_sync(struct ice_hw *hw, struct ice_flow_prof *prof, */ exist = ice_flow_acl_find_scen_entry_cond(prof, e, &do_chg_action, &do_add_entry, &do_rem_entry); - if (do_rem_entry) { status = ice_flow_rem_entry_sync(hw, ICE_BLK_ACL, exist); if (status) @@ -2869,8 +2868,11 @@ ice_flow_acl_add_scen_entry_sync(struct ice_hw *hw, struct ice_flow_prof *prof, } /* Prepare the result action buffer */ - acts = (struct ice_acl_act_entry *)ice_calloc - (hw, e->entry_sz, sizeof(struct ice_acl_act_entry)); + acts = (struct ice_acl_act_entry *) + ice_calloc(hw, e->entry_sz, sizeof(struct ice_acl_act_entry)); + if (!acts) + return ICE_ERR_NO_MEMORY; + for (i = 0; i < e->acts_cnt; i++) ice_memcpy(&acts[i], &e->acts[i].data.acl_act, sizeof(struct ice_acl_act_entry), @@ -2937,8 +2939,7 @@ ice_flow_acl_add_scen_entry_sync(struct ice_hw *hw, struct ice_flow_prof *prof, *(entry) = exist; } out: - if (acts) - ice_free(hw, acts); + ice_free(hw, acts); return status; }