From 739dee1f22d9d2d537fe5d38bb90ba29606e0196 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Tue, 2 Mar 2021 15:23:56 +0800 Subject: [PATCH] net/ice/base: fix uninitialized struct One of the structs being used for ACL counter rules was allocated on the stack and left uninitialized. Rather than depending on undefined behavior around the .amount member during rule removal, just leave a comment and initialize the struct to zero, as this is a slow path call anyway. This bug could have caused silent failures during counter removal. Fixes: f3202a097f12 ("net/ice/base: add ACL module") Cc: stable@dpdk.org Signed-off-by: Jesse Brandeburg Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/base/ice_flow.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c index a081fbe5a4..d123206fc6 100644 --- a/drivers/net/ice/base/ice_flow.c +++ b/drivers/net/ice/base/ice_flow.c @@ -1795,9 +1795,14 @@ ice_flow_acl_free_act_cntr(struct ice_hw *hw, struct ice_flow_action *acts, if (acts[i].type == ICE_FLOW_ACT_CNTR_PKT || acts[i].type == ICE_FLOW_ACT_CNTR_BYTES || acts[i].type == ICE_FLOW_ACT_CNTR_PKT_BYTES) { - struct ice_acl_cntrs cntrs; + struct ice_acl_cntrs cntrs = { 0 }; enum ice_status status; + /* amount is unused in the dealloc path but the common + * parameter check routine wants a value set, as zero + * is invalid for the check. Just set it. + */ + cntrs.amount = 1; cntrs.bank = 0; /* Only bank0 for the moment */ cntrs.first_cntr = LE16_TO_CPU(acts[i].data.acl_act.value); @@ -2396,7 +2401,7 @@ ice_flow_acl_check_actions(struct ice_hw *hw, struct ice_flow_action *acts, if (acts[i].type == ICE_FLOW_ACT_CNTR_PKT || acts[i].type == ICE_FLOW_ACT_CNTR_BYTES || acts[i].type == ICE_FLOW_ACT_CNTR_PKT_BYTES) { - struct ice_acl_cntrs cntrs; + struct ice_acl_cntrs cntrs = { 0 }; enum ice_status status; cntrs.amount = 1; -- 2.20.1