From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A85BDA0613 for ; Thu, 29 Aug 2019 04:35:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C23D61C2EF; Thu, 29 Aug 2019 04:35:04 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 32D1C1C21E; Thu, 29 Aug 2019 04:34:49 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Aug 2019 19:34:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,442,1559545200"; d="scan'208";a="332363591" Received: from dpdk51.sh.intel.com ([10.67.110.245]) by orsmga004.jf.intel.com with ESMTP; 28 Aug 2019 19:34:47 -0700 From: Qi Zhang To: wenzhuo.lu@intel.com, qiming.yang@intel.com Cc: dev@dpdk.org, xiaolong.ye@intel.com, Qi Zhang , stable@dpdk.org, Dan Nowlin , Paul M Stillwell Jr Date: Thu, 29 Aug 2019 10:36:11 +0800 Message-Id: <20190829023656.8220-19-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190829023656.8220-1-qi.z.zhang@intel.com> References: <20190826105105.19121-1-qi.z.zhang@intel.com> <20190829023656.8220-1-qi.z.zhang@intel.com> Subject: [dpdk-stable] [PATCH v2 18/63] net/ice/base: resolve static analysis issues X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Coverity complains first_free can be -1 resulting in a negative shift left when k equals 0; i.e. the expression 1 << (first_free - k). Fix this by explicitly checking for this case. Cc: stable@dpdk.org Signed-off-by: Dan Nowlin Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang --- drivers/net/ice/base/ice_flex_pipe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c index 29888df76..73362c909 100644 --- a/drivers/net/ice/base/ice_flex_pipe.c +++ b/drivers/net/ice/base/ice_flex_pipe.c @@ -4200,7 +4200,7 @@ ice_update_fd_swap(struct ice_hw *hw, u16 prof_id, struct ice_fv_word *es) index = i + 1; /* check for room */ - if (first_free + 1 < ice_fd_pairs[index].count) + if (first_free + 1 < (s8)ice_fd_pairs[index].count) return ICE_ERR_MAX_LIMIT; /* place in extraction sequence */ @@ -4210,6 +4210,9 @@ ice_update_fd_swap(struct ice_hw *hw, u16 prof_id, struct ice_fv_word *es) es[first_free - k].off = ice_fd_pairs[index].off + (k * 2); + if (k > first_free) + return ICE_ERR_OUT_OF_RANGE; + /* keep track of non-relevant fields */ mask_sel |= 1 << (first_free - k); } -- 2.13.6