From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 98E2AA0545; Tue, 11 Oct 2022 10:44:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 45C9F42829; Tue, 11 Oct 2022 10:44:44 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id DAEDF40F19 for ; Tue, 11 Oct 2022 10:44:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665477883; x=1697013883; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1DKXCvCUroiDTlkvxmO7y+WsA972VZ+CDsOpo+lYQm0=; b=SPOkiUBy9yi59ZaTG0GO4j+THBeNxxvREB+NUAP+CDNe6n0DlgWXmnuT Kp8SzZqVAONrYIFMMbrOcKplazcZ2W5Jjqux5jfuvj9EybMT243FBEjNe mQo9OnLYQ4QzNXs29YVpUS0520seUzWuC4BX1xmRjbtXxl43wVFse367s +KhqINpTrgAGch6l5iBVjytATpsmmqRo/no1j23sxrcoWafdDI5ymQdQS ayNTnIVA9iwgzml3OH/zKIMDzByp0DCQKgnVnlSdhur+LIawQ3kzq1AEb /eB2j8k0BwPfbzyJT0gM71PCWSIuunVZkoUDxPpuC19PAroD4UHukIytu Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10496"; a="368611978" X-IronPort-AV: E=Sophos;i="5.95,175,1661842800"; d="scan'208";a="368611978" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2022 01:44:41 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10496"; a="628612284" X-IronPort-AV: E=Sophos;i="5.95,175,1661842800"; d="scan'208";a="628612284" Received: from intel-cd-odc-steve.cd.intel.com ([10.240.178.133]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2022 01:44:39 -0700 From: Steve Yang To: dev@dpdk.org Cc: jingjing.wu@intel.com, beilei.xing@intel.com, Steve Yang Subject: [PATCH v1] net/iavf: fix taninted scalar Date: Tue, 11 Oct 2022 08:34:07 +0000 Message-Id: <20221011083407.1313021-1-stevex.yang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Passing tainted expression "rss_meta->proto_hdrs.count" to "iavf_refine_proto_hdrs", wich uses it as a loop boundary. Replace tainted expression with a temp variable to avoid the trainted scalar coverity warning. Coverity issue: 381131 Fixes: f30157d988cf ("net/iavf: support PPPoL2TPv2oUDP RSS Hash") Signed-off-by: Steve Yang --- drivers/net/iavf/iavf_hash.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c index dea4e0aa0a..71c80d2c75 100644 --- a/drivers/net/iavf/iavf_hash.c +++ b/drivers/net/iavf/iavf_hash.c @@ -992,9 +992,10 @@ iavf_refine_proto_hdrs_l234(struct virtchnl_proto_hdrs *proto_hdrs, uint64_t rss_type) { struct virtchnl_proto_hdr *hdr; + int phdrs_count = proto_hdrs->count; int i; - for (i = 0; i < proto_hdrs->count; i++) { + for (i = 0; i < phdrs_count; i++) { hdr = &proto_hdrs->proto_hdr[i]; switch (hdr->type) { case VIRTCHNL_PROTO_HDR_ETH: @@ -1183,12 +1184,13 @@ iavf_refine_proto_hdrs_gtpu(struct virtchnl_proto_hdrs *proto_hdrs, uint64_t rss_type) { struct virtchnl_proto_hdr *hdr; + int phdrs_count = proto_hdrs->count; int i; if (!(rss_type & RTE_ETH_RSS_GTPU)) return; - for (i = 0; i < proto_hdrs->count; i++) { + for (i = 0; i < phdrs_count; i++) { hdr = &proto_hdrs->proto_hdr[i]; switch (hdr->type) { case VIRTCHNL_PROTO_HDR_GTPU_IP: @@ -1208,6 +1210,7 @@ iavf_refine_proto_hdrs_by_pattern(struct virtchnl_proto_hdrs *proto_hdrs, struct virtchnl_proto_hdr *hdr2; int i, shift_count = 1; int tun_lvl = proto_hdrs->tunnel_level; + int phdrs_count = proto_hdrs->count; if (!(phint & IAVF_PHINT_GTPU_MSK) && !(phint & IAVF_PHINT_GRE)) return; @@ -1217,7 +1220,7 @@ iavf_refine_proto_hdrs_by_pattern(struct virtchnl_proto_hdrs *proto_hdrs, shift_count = 2; /* shift headers layer */ - for (i = proto_hdrs->count - 1 + shift_count; + for (i = phdrs_count - 1 + shift_count; i > shift_count - 1; i--) { hdr1 = &proto_hdrs->proto_hdr[i]; hdr2 = &proto_hdrs->proto_hdr[i - shift_count]; @@ -1278,6 +1281,7 @@ iavf_refine_proto_hdrs_l2tpv2(struct virtchnl_proto_hdrs *proto_hdrs, uint64_t phint) { struct virtchnl_proto_hdr *hdr, *hdr1; + int phdrs_count = proto_hdrs->count; int i; if (!(phint & IAVF_PHINT_L2TPV2) && !(phint & IAVF_PHINT_L2TPV2_LEN)) @@ -1285,7 +1289,7 @@ iavf_refine_proto_hdrs_l2tpv2(struct virtchnl_proto_hdrs *proto_hdrs, if (proto_hdrs->tunnel_level == TUNNEL_LEVEL_INNER) { /* shift headers layer */ - for (i = proto_hdrs->count - 1 + 1; i > 0; i--) + for (i = phdrs_count; i > 0; i--) proto_hdrs->proto_hdr[i] = proto_hdrs->proto_hdr[i - 1]; /* adding outer ip header at layer 0 */ @@ -1298,7 +1302,7 @@ iavf_refine_proto_hdrs_l2tpv2(struct virtchnl_proto_hdrs *proto_hdrs, else if (phint & IAVF_PHINT_OUTER_IPV6) VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, IPV6); } else { - for (i = 0; i < proto_hdrs->count; i++) { + for (i = 0; i < phdrs_count; i++) { hdr = &proto_hdrs->proto_hdr[i]; if (hdr->type == VIRTCHNL_PROTO_HDR_L2TPV2) { if (phint & IAVF_PHINT_L2TPV2) { @@ -1309,7 +1313,6 @@ iavf_refine_proto_hdrs_l2tpv2(struct virtchnl_proto_hdrs *proto_hdrs, } } } - } static void iavf_refine_proto_hdrs(struct virtchnl_proto_hdrs *proto_hdrs, -- 2.25.1