Re: [PATCH 7/8] staging: rtl: use eth_hw_addr_set()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 3 Nov 2021 14:29:06 +0300 Dan Carpenter wrote:
> >  	if (!priv->AutoloadFailFlag) {
> > +		u8 addr[ETH_ALEN];
> > +
> >  		for (i = 0; i < 6; i += 2) {
> >  			usValue = rtl92e_eeprom_read(dev,
> >  				 (EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1);
> > -			*(u16 *)(&dev->dev_addr[i]) = usValue;
> > +			*(u16 *)(&addr[i]) = usValue;  
> 
> No this doesn't work.  It writes 2 bytes instead of one so it will
> write one element beyond the end of addr[]. 

But the index moves by 2, IOW loop is only executed for i = 0, 2, 4.

> It doesn't work at all on little endian systems.

Indeed.

> I'm not sure what's going on here or how to fix it but array overflows
> are always bad.

Same :(




[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux