]> git.baikalelectronics.ru Git - kernel.git/commitdiff
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)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 13 Apr 2021 18:50:38 +0000 (11:50 -0700)
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: a0a8d42af356 ("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>
drivers/net/ethernet/intel/ice/ice_dcb.c

index 211ac6f907adb39e3d7c54029f128a3eacc6f73a..28e834a128c07be428b17a5d46d0a784394e6227 100644 (file)
@@ -747,8 +747,8 @@ ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp *cee_cfg,
                   struct ice_port_info *pi)
 {
        u32 status, tlv_status = le32_to_cpu(cee_cfg->tlv_status);
-       u32 ice_aqc_cee_status_mask, ice_aqc_cee_status_shift;
-       u8 i, j, err, sync, oper, app_index, ice_app_sel_type;
+       u32 ice_aqc_cee_status_mask, ice_aqc_cee_status_shift, j;
+       u8 i, err, sync, oper, app_index, ice_app_sel_type;
        u16 app_prio = le16_to_cpu(cee_cfg->oper_app_prio);
        u16 ice_aqc_cee_app_mask, ice_aqc_cee_app_shift;
        struct ice_dcbx_cfg *cmp_dcbcfg, *dcbcfg;