diff options
author | Bruce Allan <bruce.w.allan@intel.com> | 2019-02-08 23:50:35 +0300 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2019-02-25 19:56:01 +0300 |
commit | 32a64994dbc3e79250f99802faddc074fa8ce667 (patch) | |
tree | 159f3e8ad1e3a04d2f5efe739e73fa7762bdc73e /drivers/net/ethernet/intel/ice/ice_nvm.c | |
parent | 0e04e8e14b558c84a7c7a64d3e94655f5071eef5 (diff) | |
download | linux-32a64994dbc3e79250f99802faddc074fa8ce667.tar.xz |
ice: fix numeric overflow warning
When compiling and analyzing the driver on newer kernels, a static
analyzer warns about the following "numeric overflow" issues:
"The result of expression: 'budget-1' generates 4-byte type while casting
to a bigger size of 8-byte".
"The result of expression: '*words-words_read' generates 4-byte type
while casting to a bigger size of 8-byte".
Fix them both.
Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_nvm.c')
-rw-r--r-- | drivers/net/ethernet/intel/ice/ice_nvm.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c index ce64cecdae9c..413fdbbcc4d0 100644 --- a/drivers/net/ethernet/intel/ice/ice_nvm.c +++ b/drivers/net/ethernet/intel/ice/ice_nvm.c @@ -152,9 +152,10 @@ ice_read_sr_buf_aq(struct ice_hw *hw, u16 offset, u16 *words, u16 *data) */ off_w = offset % ICE_SR_SECTOR_SIZE_IN_WORDS; read_size = off_w ? - min(*words, - (u16)(ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) : - min((*words - words_read), ICE_SR_SECTOR_SIZE_IN_WORDS); + min_t(u16, *words, + (ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) : + min_t(u16, (*words - words_read), + ICE_SR_SECTOR_SIZE_IN_WORDS); /* Check if this is last command, if so set proper flag */ if ((words_read + read_size) >= *words) |