From patchwork Tue Mar 2 07:23:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 88361 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6FD77A054F; Tue, 2 Mar 2021 08:21:45 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8886522A280; Tue, 2 Mar 2021 08:20:50 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id CF8B722A27C; Tue, 2 Mar 2021 08:20:47 +0100 (CET) IronPort-SDR: QuTxR/3MgxslPiGf6a8N1jV99kMhJEyjzvN1XCN4sK1Wvu2noUzUFtJc5A1R1V1s+tSAI/92jS 37v0+wl16UCg== X-IronPort-AV: E=McAfee;i="6000,8403,9910"; a="186775344" X-IronPort-AV: E=Sophos;i="5.81,216,1610438400"; d="scan'208";a="186775344" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2021 23:20:47 -0800 IronPort-SDR: onKBisyhQEMQwdMCARaQlwXB3XJ8zpk+dEs9p2F0pXMsUrcJkgJzqzJ90vZ2u8qxyIUA8Z92ZG N0iQn4jqIIBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,216,1610438400"; d="scan'208";a="506230465" Received: from dpdk51.sh.intel.com ([10.67.111.142]) by fmsmga001.fm.intel.com with ESMTP; 01 Mar 2021 23:20:44 -0800 From: Qi Zhang To: qiming.yang@intel.com Cc: dev@dpdk.org, haiyue.wang@intel.com, junfeng.guo@intel.com, Qi Zhang , stable@dpdk.org, Jesse Brandeburg Date: Tue, 2 Mar 2021 15:23:56 +0800 Message-Id: <20210302072357.1657556-14-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210302072357.1657556-1-qi.z.zhang@intel.com> References: <20210302072357.1657556-1-qi.z.zhang@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 13/14] net/ice/base: fix uninitialized struct X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" 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 --- 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;