from : [email protected] Fixed calculation of the number of words which shall be written to the EEPROM when calling e100_set_eeprom.
Signed-off-by: Julian Friedrich <[email protected]> --- Hello... 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 be written. 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) return -EINVAL; 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 <[email protected]> ------------------------------------------------------------------------------ Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery and much more. Keep your Java skills current with LearnJavaNow - 200+ hours of step-by-step video tutorials by Java experts. SALE $49.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122612 _______________________________________________ E1000-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/e1000-devel To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
