From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@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 <dev@dpdk.org>; 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 <qi.z.zhang@intel.com>
To: ferruh.yigit@intel.com
Cc: dev@dpdk.org, Qi Zhang <qi.z.zhang@intel.com>,
 Tony Nguyen <anthony.l.nguyen@intel.com>
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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

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 <anthony.l.nguyen@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
---
 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;
 }
-- 
2.13.6