diff mbox series

[18/63] net/ice/base: resolve static analysis issues

Message ID 20190826105105.19121-19-qi.z.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers show
Series net/ice/base: update base code | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Zhang, Qi Z Aug. 26, 2019, 10:50 a.m. UTC
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 <dan.nowlin@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/base/ice_flex_pipe.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

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);
 			}