aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtlwifi
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2014-03-10 19:53:10 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-03-13 14:05:40 -0400
commit4e3b3bcd81776527fa6f11624d68849de8c8802e (patch)
tree3d63e3f9080c7c13abafbfbc0514278899fa02d3 /drivers/net/wireless/rtlwifi
parent3ead0d2e220ea7ced14027336bb168bafa01b7af (diff)
rtlwifi: rtl8723be: Fix array dimension problems
Commit a619d1abe20c leads to the following static checker warning: drivers/net/wireless/rtlwifi/rtl8723be/phy.c:667 _rtl8723be_store_tx_power_by_rate() error: buffer overflow 'rtlphy->tx_power_by_rate_offset[band]' 4 <= 5 This warning arises because the code is testing the indices for the wrong maximum values. In addition, the tests merely putput a warning, and then procedes to corrupt memory. With this change, any such invalid memory access is avoided. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rtlwifi')
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8723be/phy.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/phy.c b/drivers/net/wireless/rtlwifi/rtl8723be/phy.c
index cadae9bc4e3f..1575ef9ece9f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8723be/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8723be/phy.c
@@ -629,18 +629,22 @@ static void _rtl8723be_store_tx_power_by_rate(struct ieee80211_hw *hw,
629 struct rtl_phy *rtlphy = &(rtlpriv->phy); 629 struct rtl_phy *rtlphy = &(rtlpriv->phy);
630 u8 rate_section = _rtl8723be_get_rate_section_index(regaddr); 630 u8 rate_section = _rtl8723be_get_rate_section_index(regaddr);
631 631
632 if (band != BAND_ON_2_4G && band != BAND_ON_5G) 632 if (band != BAND_ON_2_4G && band != BAND_ON_5G) {
633 RT_TRACE(rtlpriv, COMP_POWER, PHY_TXPWR, 633 RT_TRACE(rtlpriv, COMP_POWER, PHY_TXPWR,
634 "Invalid Band %d\n", band); 634 "Invalid Band %d\n", band);
635 return;
636 }
635 637
636 if (rfpath > MAX_RF_PATH) 638 if (rfpath > TX_PWR_BY_RATE_NUM_RF) {
637 RT_TRACE(rtlpriv, COMP_POWER, PHY_TXPWR, 639 RT_TRACE(rtlpriv, COMP_POWER, PHY_TXPWR,
638 "Invalid RfPath %d\n", rfpath); 640 "Invalid RfPath %d\n", rfpath);
639 641 return;
640 if (txnum > MAX_RF_PATH) 642 }
643 if (txnum > TX_PWR_BY_RATE_NUM_RF) {
641 RT_TRACE(rtlpriv, COMP_POWER, PHY_TXPWR, 644 RT_TRACE(rtlpriv, COMP_POWER, PHY_TXPWR,
642 "Invalid TxNum %d\n", txnum); 645 "Invalid TxNum %d\n", txnum);
643 646 return;
647 }
644 rtlphy->tx_power_by_rate_offset[band][rfpath][txnum][rate_section] = 648 rtlphy->tx_power_by_rate_offset[band][rfpath][txnum][rate_section] =
645 data; 649 data;
646} 650}