summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-05-30 15:26:16 (GMT)
committerKalle Valo <kvalo@codeaurora.org>2016-06-16 15:13:33 (GMT)
commit5345ea6a4bfb956b1d021fbd9c62daa921942d85 (patch)
tree39ee7b9592c08bfab241b55c42f6f228dd0e0d37 /drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
parentfd3667a8d1cb17f0a91771805be4efaa5c35cda1 (diff)
downloadlinux-5345ea6a4bfb956b1d021fbd9c62daa921942d85.tar.xz
rtlwifi: fix error handling in *_read_adapter_info()
There are nine copies of the _rtl88ee_read_adapter_info() function, and most but not all of them cause a build warning in some configurations: rtl8192de/hw.c: In function '_rtl92de_read_adapter_info': rtl8192de/hw.c:1767:12: error: 'hwinfo' may be used uninitialized in this function [-Werror=maybe-uninitialized] rtl8723ae/hw.c: In function '_rtl8723e_read_adapter_info.constprop': rtlwifi/rtl8723ae/hw.c:1654:12: error: 'hwinfo' may be used uninitialized in this function [-Werror=maybe-uninitialized] The problem is that when rtlefuse->epromtype is something other than EEPROM_BOOT_EFUSE, the rest of the function uses undefined data, resulting in random behavior later. Apparently, in some drivers, the problem was already found and fixed but the fix did not make it into the others. This picks one approach to deal with the problem and applies identical code to all 9 files, to simplify the later consolidation of those. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c')
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
index 71e4dd9..b9436df 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
@@ -3101,6 +3101,7 @@ static void _rtl8821ae_read_adapter_info(struct ieee80211_hw *hw, bool b_pseudo_
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
+ struct device *dev = &rtl_pcipriv(hw)->dev.pdev->dev;
u16 i, usvalue;
u8 hwinfo[HWSET_MAX_SIZE];
u16 eeprom_id;
@@ -3109,14 +3110,20 @@ static void _rtl8821ae_read_adapter_info(struct ieee80211_hw *hw, bool b_pseudo_
;/* need add */
}
- if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) {
+ switch (rtlefuse->epromtype) {
+ case EEPROM_BOOT_EFUSE:
rtl_efuse_shadow_map_update(hw);
- memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0],
- HWSET_MAX_SIZE);
- } else if (rtlefuse->epromtype == EEPROM_93C46) {
+ break;
+
+ case EEPROM_93C46:
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
"RTL819X Not boot from eeprom, check it !!");
+ return;
+
+ default:
+ dev_warn(dev, "no efuse data\n");
}
+ memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE);
RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP\n",
hwinfo, HWSET_MAX_SIZE);