diff options
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_ethtool.c')
| -rw-r--r-- | drivers/net/ethernet/intel/ice/ice_ethtool.c | 6 | 
1 files changed, 4 insertions, 2 deletions
| diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index b360bd8f1599..f86e814354a3 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -4331,6 +4331,8 @@ ice_get_module_eeprom(struct net_device *netdev,  		 * SFP modules only ever use page 0.  		 */  		if (page == 0 || !(data[0x2] & 0x4)) { +			u32 copy_len; +  			/* If i2c bus is busy due to slow page change or  			 * link management access, call can fail. This is normal.  			 * So we retry this a few times. @@ -4354,8 +4356,8 @@ ice_get_module_eeprom(struct net_device *netdev,  			}  			/* Make sure we have enough room for the new block */ -			if ((i + SFF_READ_BLOCK_SIZE) < ee->len) -				memcpy(data + i, value, SFF_READ_BLOCK_SIZE); +			copy_len = min_t(u32, SFF_READ_BLOCK_SIZE, ee->len - i); +			memcpy(data + i, value, copy_len);  		}  	}  	return 0; |