lkml.org 
[lkml]   [2020]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net-next v1 5/5] hinic: add support to get eeprom information
From
Date
On 2020/6/21 0:00, Andrew Lunn wrote:
>> +static int hinic_get_module_eeprom(struct net_device *netdev,
>> + struct ethtool_eeprom *ee, u8 *data)
>> +{
>> + struct hinic_dev *nic_dev = netdev_priv(netdev);
>> + u8 sfp_data[STD_SFP_INFO_MAX_SIZE];
>
> sfp_data will contain whatever is on the stack.
>
>> + u16 len;
>> + int err;
>> +
>> + if (!ee->len || ((ee->len + ee->offset) > STD_SFP_INFO_MAX_SIZE))
>> + return -EINVAL;
>> +
>> + memset(data, 0, ee->len);
>
> This clears what you are going to return.
>
>> +
>> + err = hinic_get_sfp_eeprom(nic_dev->hwdev, sfp_data, &len);
>
> Upto len bytes of sfp_data now contain useful data. The rest of
> sfp_data is still stack data.
>
>
>> + if (err)
>> + return err;
>> +
>> + memcpy(data, sfp_data + ee->offset, ee->len);
>
> If len < ee->len, you have just returned to user space some stack data.
>
> Andrew
> .
>
The whole sfp_data will be assigned values in hinic_get_sfp_eeprom function,
so stack data won't be returned to user space. Thanks for your review.

\
 
 \ /
  Last update: 2020-06-22 04:05    [W:0.087 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site