]> git.droids-corp.org - dpdk.git/commitdiff
net/ice/base: fix uninitialized struct
authorQi Zhang <qi.z.zhang@intel.com>
Tue, 2 Mar 2021 07:23:56 +0000 (15:23 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Fri, 5 Mar 2021 08:36:18 +0000 (09:36 +0100)
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 <jesse.brandeburg@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

index a081fbe5a4b42574324ebf1eec460d3792b986b3..d123206fc6c46928989b041ac666a0b37d75d4c3 100644 (file)
@@ -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;