On 04/10/20 1:08 am, Joe Perches wrote:
> On Thu, 2020-10-01 at 13:02 +0530, Anant Thazhemadam wrote:
>> When get_registers() fails (which happens when usb_control_msg() fails)
>> in set_ethernet_addr(), the uninitialized value of node_id gets copied
>> as the address.
> unrelated trivia:
>
>> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> []
>> @@ -274,12 +274,17 @@ static int write_mii_word(rtl8150_t * dev, u8 phy, 
>> __u8 indx, u16 reg)
>>              return 1;
>>  }
>>  
>> -static inline void set_ethernet_addr(rtl8150_t * dev)
>> +static bool set_ethernet_addr(rtl8150_t *dev)
>>  {
>>      u8 node_id[6];
> This might be better as:
>
>       u8 node_id[ETH_ALEN];
>
>> +    int ret;
>>  
>> -    get_registers(dev, IDR, sizeof(node_id), node_id);
>> -    memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id));
>> +    ret = get_registers(dev, IDR, sizeof(node_id), node_id);
>> +    if (ret == sizeof(node_id)) {
>> +            memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id));
> and
>               ether_addr_copy(dev->netdev->dev_addr, node_id);
>
>
I will include this change as well, in the v3.
Thank you for pointing that out.

Thanks,
Anant

Reply via email to