From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 83C535A8C for ; Tue, 31 Mar 2015 10:57:02 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 31 Mar 2015 01:57:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,499,1422950400"; d="scan'208";a="700679027" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by fmsmga002.fm.intel.com with ESMTP; 31 Mar 2015 01:57:00 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by PGSMSX106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 31 Mar 2015 16:57:00 +0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.80]) by shsmsx102.ccr.corp.intel.com ([169.254.2.223]) with mapi id 14.03.0224.002; Tue, 31 Mar 2015 16:56:59 +0800 From: "Cao, Min" To: "Wu, Jingjing" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] i40e: fix the issue reported by klocwork Thread-Index: AQHQRrY/ySgLcZHdekKDXTb8PJuiUp02kwzg Date: Tue, 31 Mar 2015 08:56:58 +0000 Message-ID: References: <1423740143-29708-1-git-send-email-jingjing.wu@intel.com> In-Reply-To: <1423740143-29708-1-git-send-email-jingjing.wu@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] i40e: fix the issue reported by klocwork X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2015 08:57:03 -0000 Tested-by: Min Cao Patch name: [dpdk-dev] [PATCH] i40e: fix the issue reported by klocwork Test Flag: Tested-by Tester name: min.cao@intel.com Result summary: total 2 cases, 2passed, 0 failed Test Case 1: =09 Name: ipv4 fwd Environment: OS: Fedora20 3.11.10-301.fc20.x86_64 gcc (GCC) 4.8.2 CPU: Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz NIC: Fortville eagle=20 Test result: PASSED Detail: ipv4 fwd Test Case 2: =09 Name: ipv6 fwd Environment: OS: Fedora20 3.11.10-301.fc20.x86_64 gcc (GCC) 4.8.2 CPU: Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz NIC: Fortville eagle=20 Test result: PASSED Detail: ipv6 fwd =09 -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jingjing Wu Sent: Thursday, February 12, 2015 7:22 PM To: dev@dpdk.org Subject: [dpdk-dev] [PATCH] i40e: fix the issue reported by klocwork Klocwork reports array 'src_offset' may use index 16. In function i40e_srcoff_to_flx_pit, index j + 1 can reach I40E_FDIR_MAX_FLE= X_LEN. This patch fixes this issue to avoid array bound. Signed-off-by: Jingjing Wu --- lib/librte_pmd_i40e/i40e_fdir.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_fdir.c b/lib/librte_pmd_i40e/i40e_fdi= r.c index 68511c8..bc36d8e 100644 --- a/lib/librte_pmd_i40e/i40e_fdir.c +++ b/lib/librte_pmd_i40e/i40e_fdir.c @@ -402,28 +402,27 @@ i40e_srcoff_to_flx_pit(const uint16_t *src_offset, =20 while (j < I40E_FDIR_MAX_FLEX_LEN) { size =3D 1; - for (; j < I40E_FDIR_MAX_FLEX_LEN; j++) { + for (; j < I40E_FDIR_MAX_FLEX_LEN - 1; j++) { if (src_offset[j + 1] =3D=3D src_offset[j] + 1) size++; - else { - src_tmp =3D src_offset[j] + 1 - size; - /* the flex_pit need to be sort by scr_offset */ - for (i =3D 0; i < num; i++) { - if (src_tmp < flex_pit[i].src_offset) - break; - } - /* if insert required, move backward */ - for (k =3D num; k > i; k--) - flex_pit[k] =3D flex_pit[k - 1]; - /* insert */ - flex_pit[i].dst_offset =3D j + 1 - size; - flex_pit[i].src_offset =3D src_tmp; - flex_pit[i].size =3D size; - j++; - num++; + else + break; + } + src_tmp =3D src_offset[j] + 1 - size; + /* the flex_pit need to be sort by src_offset */ + for (i =3D 0; i < num; i++) { + if (src_tmp < flex_pit[i].src_offset) break; - } } + /* if insert required, move backward */ + for (k =3D num; k > i; k--) + flex_pit[k] =3D flex_pit[k - 1]; + /* insert */ + flex_pit[i].dst_offset =3D j + 1 - size; + flex_pit[i].src_offset =3D src_tmp; + flex_pit[i].size =3D size; + j++; + num++; } return num; } --=20 1.9.3