diff options
author | David Ertman <david.m.ertman@intel.com> | 2014-07-09 12:07:42 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2014-07-25 23:51:00 -0400 |
commit | 491a04d2812b0a665bda34ea39875833dc7a1aaf (patch) | |
tree | dccfd1e8134272c43c712d10f7f83ebadce1b1de /drivers/net | |
parent | 493004d04f56fd7d642bdbb2938e17e5f7d622d1 (diff) |
e1000e: Add code to check return values on NVM accesses
Adding code to check and respond to previously ignored return values
from NVM access functions.
Issue discovered through static analysis.
Signed-off-by: Dave Ertman <david.m.ertman@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/intel/e1000e/manage.c | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/e1000e/netdev.c | 22 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/e1000e/nvm.c | 4 |
3 files changed, 23 insertions, 8 deletions
diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c index cb37ff1f1321..58856032298d 100644 --- a/drivers/net/ethernet/intel/e1000e/manage.c +++ b/drivers/net/ethernet/intel/e1000e/manage.c | |||
@@ -327,9 +327,12 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) | |||
327 | } else if ((hw->mac.type == e1000_82574) || | 327 | } else if ((hw->mac.type == e1000_82574) || |
328 | (hw->mac.type == e1000_82583)) { | 328 | (hw->mac.type == e1000_82583)) { |
329 | u16 data; | 329 | u16 data; |
330 | s32 ret_val; | ||
330 | 331 | ||
331 | factps = er32(FACTPS); | 332 | factps = er32(FACTPS); |
332 | e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data); | 333 | ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data); |
334 | if (ret_val) | ||
335 | return false; | ||
333 | 336 | ||
334 | if (!(factps & E1000_FACTPS_MNGCG) && | 337 | if (!(factps & E1000_FACTPS_MNGCG) && |
335 | ((data & E1000_NVM_INIT_CTRL2_MNGM) == | 338 | ((data & E1000_NVM_INIT_CTRL2_MNGM) == |
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 201cc93f3625..fe3e42a6c8e9 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c | |||
@@ -6708,6 +6708,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
6708 | int bars, i, err, pci_using_dac; | 6708 | int bars, i, err, pci_using_dac; |
6709 | u16 eeprom_data = 0; | 6709 | u16 eeprom_data = 0; |
6710 | u16 eeprom_apme_mask = E1000_EEPROM_APME; | 6710 | u16 eeprom_apme_mask = E1000_EEPROM_APME; |
6711 | s32 rval = 0; | ||
6711 | 6712 | ||
6712 | if (ei->flags2 & FLAG2_DISABLE_ASPM_L0S) | 6713 | if (ei->flags2 & FLAG2_DISABLE_ASPM_L0S) |
6713 | aspm_disable_flag = PCIE_LINK_STATE_L0S; | 6714 | aspm_disable_flag = PCIE_LINK_STATE_L0S; |
@@ -6940,15 +6941,19 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
6940 | } else if (adapter->flags & FLAG_APME_IN_CTRL3) { | 6941 | } else if (adapter->flags & FLAG_APME_IN_CTRL3) { |
6941 | if (adapter->flags & FLAG_APME_CHECK_PORT_B && | 6942 | if (adapter->flags & FLAG_APME_CHECK_PORT_B && |
6942 | (adapter->hw.bus.func == 1)) | 6943 | (adapter->hw.bus.func == 1)) |
6943 | e1000_read_nvm(&adapter->hw, NVM_INIT_CONTROL3_PORT_B, | 6944 | rval = e1000_read_nvm(&adapter->hw, |
6944 | 1, &eeprom_data); | 6945 | NVM_INIT_CONTROL3_PORT_B, |
6946 | 1, &eeprom_data); | ||
6945 | else | 6947 | else |
6946 | e1000_read_nvm(&adapter->hw, NVM_INIT_CONTROL3_PORT_A, | 6948 | rval = e1000_read_nvm(&adapter->hw, |
6947 | 1, &eeprom_data); | 6949 | NVM_INIT_CONTROL3_PORT_A, |
6950 | 1, &eeprom_data); | ||
6948 | } | 6951 | } |
6949 | 6952 | ||
6950 | /* fetch WoL from EEPROM */ | 6953 | /* fetch WoL from EEPROM */ |
6951 | if (eeprom_data & eeprom_apme_mask) | 6954 | if (rval) |
6955 | e_dbg("NVM read error getting WoL initial values: %d\n", rval); | ||
6956 | else if (eeprom_data & eeprom_apme_mask) | ||
6952 | adapter->eeprom_wol |= E1000_WUFC_MAG; | 6957 | adapter->eeprom_wol |= E1000_WUFC_MAG; |
6953 | 6958 | ||
6954 | /* now that we have the eeprom settings, apply the special cases | 6959 | /* now that we have the eeprom settings, apply the special cases |
@@ -6967,7 +6972,12 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
6967 | device_wakeup_enable(&pdev->dev); | 6972 | device_wakeup_enable(&pdev->dev); |
6968 | 6973 | ||
6969 | /* save off EEPROM version number */ | 6974 | /* save off EEPROM version number */ |
6970 | e1000_read_nvm(&adapter->hw, 5, 1, &adapter->eeprom_vers); | 6975 | rval = e1000_read_nvm(&adapter->hw, 5, 1, &adapter->eeprom_vers); |
6976 | |||
6977 | if (rval) { | ||
6978 | e_dbg("NVM read error getting EEPROM version: %d\n", rval); | ||
6979 | adapter->eeprom_vers = 0; | ||
6980 | } | ||
6971 | 6981 | ||
6972 | /* reset the hardware with the new settings */ | 6982 | /* reset the hardware with the new settings */ |
6973 | e1000e_reset(adapter); | 6983 | e1000e_reset(adapter); |
diff --git a/drivers/net/ethernet/intel/e1000e/nvm.c b/drivers/net/ethernet/intel/e1000e/nvm.c index b1f212b7baf7..fa6b1036a327 100644 --- a/drivers/net/ethernet/intel/e1000e/nvm.c +++ b/drivers/net/ethernet/intel/e1000e/nvm.c | |||
@@ -327,8 +327,10 @@ s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) | |||
327 | 327 | ||
328 | ew32(EERD, eerd); | 328 | ew32(EERD, eerd); |
329 | ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ); | 329 | ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ); |
330 | if (ret_val) | 330 | if (ret_val) { |
331 | e_dbg("NVM read error: %d\n", ret_val); | ||
331 | break; | 332 | break; |
333 | } | ||
332 | 334 | ||
333 | data[i] = (er32(EERD) >> E1000_NVM_RW_REG_DATA); | 335 | data[i] = (er32(EERD) >> E1000_NVM_RW_REG_DATA); |
334 | } | 336 | } |