[v2,26/40] net/ice/base: add check for failed acts allocation
diff mbox series

Message ID 20200911131954.15999-27-qi.z.zhang@intel.com
State Accepted, archived
Headers show
Series
  • ice base code update
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Zhang, Qi Z Sept. 11, 2020, 1:19 p.m. UTC
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(-)

Patch
diff mbox series

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;
 }