From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 773EB5A8C for ; Mon, 30 Mar 2015 22:15:08 +0200 (CEST) Received: by wgbdm7 with SMTP id dm7so81383408wgb.1 for ; Mon, 30 Mar 2015 13:15:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=yF+wgHr/xEkBzO+mg8oxI7k6q53Q1xGnXfZ2bUOAT9U=; b=jQPov1iOrv6wUipgGcYqd5epyElBfLqAA89Uq6wuwfLuSR0nrU4u17secm6SF8mAgL gBOSozIG4KLB2QuXTwSxp9k1racxNur3uk9Valwvfukxh05HEde6pEf+Fo3LWM3I+0a8 j5XRLTNS9a30DjxDAPoqS8LGplW0B3T47E8erOhT4n1RUkJjtSAND8ajeimQ3lu4heVv 7pY9WBlbzS8ZkAuuRReqzb1ue6tsBTizNazZ/31/ho+UhT9he5IST+vrqUgcMrs0kNpp Q5jiVsoTfsu1ISVZ8Dl/85CeDxL7W5l12Kz4FzTcL7qed5pV+kT9vL12y27V8N143I9H ZwRw== X-Gm-Message-State: ALoCoQnsObyPVQVQtF+kBmw2FqxRNtKZwzJTN/e2hZOMkgBldpiHy1vU2KXAY/T2S9zOBqc53SLA X-Received: by 10.194.2.43 with SMTP id 11mr67528053wjr.104.1427746508291; Mon, 30 Mar 2015 13:15:08 -0700 (PDT) Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id ev7sm17184684wjb.47.2015.03.30.13.15.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2015 13:15:07 -0700 (PDT) From: Thomas Monjalon To: helin.zhang@intel.com Date: Mon, 30 Mar 2015 22:14:27 +0200 Message-ID: <1651225.dfosDIXqjQ@xps13> Organization: 6WIND User-Agent: KMail/4.14.4 (Linux/3.18.4-1-ARCH; KDE/4.14.4; x86_64; ; ) In-Reply-To: <1423740143-29708-1-git-send-email-jingjing.wu@intel.com> References: <1423740143-29708-1-git-send-email-jingjing.wu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: dev@dpdk.org 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: Mon, 30 Mar 2015 20:15:08 -0000 Helin, is this patch valid and important? 2015-02-12 19:22, Jingjing Wu: > Klocwork reports array 'src_offset' may use index 16. > In function i40e_srcoff_to_flx_pit, index j + 1 can reach I40E_FDIR_MAX_FLEX_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_fdir.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, > > while (j < I40E_FDIR_MAX_FLEX_LEN) { > size = 1; > - for (; j < I40E_FDIR_MAX_FLEX_LEN; j++) { > + for (; j < I40E_FDIR_MAX_FLEX_LEN - 1; j++) { > if (src_offset[j + 1] == src_offset[j] + 1) > size++; > - else { > - src_tmp = src_offset[j] + 1 - size; > - /* the flex_pit need to be sort by scr_offset */ > - for (i = 0; i < num; i++) { > - if (src_tmp < flex_pit[i].src_offset) > - break; > - } > - /* if insert required, move backward */ > - for (k = num; k > i; k--) > - flex_pit[k] = flex_pit[k - 1]; > - /* insert */ > - flex_pit[i].dst_offset = j + 1 - size; > - flex_pit[i].src_offset = src_tmp; > - flex_pit[i].size = size; > - j++; > - num++; > + else > + break; > + } > + src_tmp = src_offset[j] + 1 - size; > + /* the flex_pit need to be sort by src_offset */ > + for (i = 0; i < num; i++) { > + if (src_tmp < flex_pit[i].src_offset) > break; > - } > } > + /* if insert required, move backward */ > + for (k = num; k > i; k--) > + flex_pit[k] = flex_pit[k - 1]; > + /* insert */ > + flex_pit[i].dst_offset = j + 1 - size; > + flex_pit[i].src_offset = src_tmp; > + flex_pit[i].size = size; > + j++; > + num++; > } > return num; > } >