ice: Fix potential infinite loop when using u8 loop counter
authorColin Ian King <colin.king@canonical.com>
Wed, 31 Mar 2021 14:46:28 +0000 (15:46 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Apr 2021 11:00:55 +0000 (13:00 +0200)
commita2af8a0f38e48e0f496870735cd931b69b78f481
tree01bdffe57594db84c2be8bbb5f8d9af482f8fe7f
parent783645e65b5774d794a60b606e8801a00e11eda3
ice: Fix potential infinite loop when using u8 loop counter

commit ef963ae427aa4669905e0a96b3bd9d44dc85db32 upstream.

A for-loop is using a u8 loop counter that is being compared to
a u32 cmp_dcbcfg->numapp to check for the end of the loop. If
cmp_dcbcfg->numapp is larger than 255 then the counter j will wrap
around to zero and hence an infinite loop occurs. Fix this by making
counter j the same type as cmp_dcbcfg->numapp.

Addresses-Coverity: ("Infinite loop")
Fixes: aeac8ce864d9 ("ice: Recognize 860 as iSCSI port in CEE mode")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/intel/ice/ice_dcb.c