[Intel-wired-lan] [PATCH net v2] ice: copy last block omitted in ice_get_module_eeprom()

Jesse Brandeburg jesse.brandeburg at intel.com
Wed Mar 1 19:26:55 UTC 2023


On 3/1/2023 9:14 AM, Petr Oros wrote:

>  drivers/net/ethernet/intel/ice/ice_ethtool.c | 6 ++++--
>  1 file 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 b360bd8f15998b..1dc3f9fc74bdfb 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> @@ -4293,6 +4293,7 @@ ice_get_module_eeprom(struct net_device *netdev,
>  	bool is_sfp = false;
>  	unsigned int i, j;
>  	u16 offset = 0;
> +	u32 copy_len;

copy_len should only be declared in the "if" below so that it's only
declared in the context it is used.

>  	u8 page = 0;
>  	int status;
>  
> @@ -4354,8 +4355,9 @@ 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);

also this line can be unwrapped now.

> +			memcpy(data + i, value, copy_len);
>  		}
>  	}
>  	return 0;

I've tested this and it fixes the problem. Interestingly, the ethtool
application when compiled without netlink support parsed the output
correctly so caused a bit of confusion around this issue.

Thank you Petr!



More information about the Intel-wired-lan mailing list