e1000e: don't return half-read eeprom on error
authorKok, Auke <auke-jan.h.kok@intel.com>
Tue, 29 Apr 2008 18:18:55 +0000 (11:18 -0700)
committerJeff Garzik <jgarzik@redhat.com>
Tue, 6 May 2008 16:38:02 +0000 (12:38 -0400)
On a read error, e1000e might have returned uninitialized block of
eeprom data back to userspace. The convention is that 0xff is "empty",
so mark the entire eeprom as empty in case of an error.

Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/net/e1000e/ethtool.c

index 2bb6da057c40de64d936a49f15257490e80493bd..a14561f40db0fddd497b4894c6b67db1d8996dc2 100644 (file)
@@ -494,8 +494,12 @@ static int e1000_get_eeprom(struct net_device *netdev,
                for (i = 0; i < last_word - first_word + 1; i++) {
                        ret_val = e1000_read_nvm(hw, first_word + i, 1,
                                                      &eeprom_buff[i]);
-                       if (ret_val)
+                       if (ret_val) {
+                               /* a read error occurred, throw away the
+                                * result */
+                               memset(eeprom_buff, 0xff, sizeof(eeprom_buff));
                                break;
+                       }
                }
        }