From: FRIEDRICH Julian <Julian.FRIEDRICH@fr...> - 2013-01-09 11:42:49
from : julian.friedrich@...
Fixed calculation of the number of words which shall be written to the EEPROM
when calling e100_set_eeprom.
Signed-off-by: Julian Friedrich <Julian.friedrich@...>
There is a bug when calculating the number of words to write to the EEPROM
within e100_set_EEPROM. Actually when writing an even number of bytes, one
more word will be written to the EEPROM then necessary. This causes an error
when trying to write EEPROMSIZE - 1 words, as this will cause the code to try
to write EEPROMSIZE words to the EEPROM. This will be prevented by
e100_eeprom_save as there is a check if more than EEPROMSIZE - 1 words shall
The error will occur as well if a user tries to write to the very end of the
EEPROM (up to the checksum which is the last word) and the number of bytes to
write is even. This will cause the code to try to write to the last word as
well. This will be prevented by e100_eeprom_save for the same reason as above.
--- drivers/net/ethernet/intel/e100.c.orig 2012-12-17 20:14:54.000000000 +0100
+++ drivers/net/ethernet/intel/e100.c 2013-01-09 11:02:41.000000000 +0100
@@ -2549,14 +2549,17 @@ static int e100_set_eeprom(struct net_de
struct ethtool_eeprom *eeprom, u8 *bytes)
struct nic *nic = netdev_priv(netdev);
+ u16 count;
if (eeprom->magic != E100_EEPROM_MAGIC)
memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len);
- return e100_eeprom_save(nic, eeprom->offset >> 1,
- (eeprom->len >> 1) + 1);
+ count = (eeprom->len + eeprom->offset + 1) >> 1;
+ count -= (eeprom->offset >> 1);
+ count = count > 0 ? count : 1;
+ return e100_eeprom_save(nic, eeprom->offset >> 1, count);
static void e100_get_ringparam(struct net_device *netdev,
Signed-off-by: Julian Friedrich <julian.friedrich@...>
Get latest updates about Open Source Projects, Conferences and News.