diff options
author | Eyal Shapira <eyal@wizery.com> | 2014-01-05 14:04:19 -0500 |
---|---|---|
committer | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2014-01-13 15:17:16 -0500 |
commit | 560843f4ab7ba8c2e5edf01949bba4d7a94f01e9 (patch) | |
tree | 5a880b673bf3dd85b3e5a5123eda8b3bc103292c | |
parent | 099d8f20b65d0dac07fb6e2ca0ed19e5d36d7d2e (diff) |
iwlwifi: mvm: rs: fix a theoretical out of bounds access
Discovered by klocwork
Array 'iwl_rate_mcs' of size 15 may use index value(s) -1
* rs.c:2562: index = iwl_hwrate_to_plcp_idx(rate)
* rs.c:2562: Result of function call 'iwl_hwrate_to_plcp_idx(rate)' is '[-1,14]'
* rs.c:2565: Array 'iwl_rate_mcs' size is 15.
* rs.c:2565: Possible attempt to access element -1 of array 'iwl_rate_mcs'.
While at it stop using index = -1 and always use IWL_RATE_INVALID
Signed-off-by: Eyal Shapira <eyalx.shapira@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/rs.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c index 54887b952eb5..c4f214d4c44e 100644 --- a/drivers/net/wireless/iwlwifi/mvm/rs.c +++ b/drivers/net/wireless/iwlwifi/mvm/rs.c | |||
@@ -357,7 +357,7 @@ static int iwl_hwrate_to_plcp_idx(u32 rate_n_flags) | |||
357 | return idx; | 357 | return idx; |
358 | } | 358 | } |
359 | 359 | ||
360 | return -1; | 360 | return IWL_RATE_INVALID; |
361 | } | 361 | } |
362 | 362 | ||
363 | static void rs_rate_scale_perform(struct iwl_mvm *mvm, | 363 | static void rs_rate_scale_perform(struct iwl_mvm *mvm, |
@@ -703,10 +703,8 @@ static int rs_rate_from_ucode_rate(const u32 ucode_rate, | |||
703 | memset(rate, 0, sizeof(*rate)); | 703 | memset(rate, 0, sizeof(*rate)); |
704 | rate->index = iwl_hwrate_to_plcp_idx(ucode_rate); | 704 | rate->index = iwl_hwrate_to_plcp_idx(ucode_rate); |
705 | 705 | ||
706 | if (rate->index == IWL_RATE_INVALID) { | 706 | if (rate->index == IWL_RATE_INVALID) |
707 | rate->index = -1; | ||
708 | return -EINVAL; | 707 | return -EINVAL; |
709 | } | ||
710 | 708 | ||
711 | rate->ant = (ant_msk >> RATE_MCS_ANT_POS); | 709 | rate->ant = (ant_msk >> RATE_MCS_ANT_POS); |
712 | 710 | ||
@@ -2562,7 +2560,9 @@ static int rs_pretty_print_rate(char *buf, const u32 rate) | |||
2562 | int index = iwl_hwrate_to_plcp_idx(rate); | 2560 | int index = iwl_hwrate_to_plcp_idx(rate); |
2563 | 2561 | ||
2564 | return sprintf(buf, "Legacy | ANT: %s Rate: %s Mbps\n", | 2562 | return sprintf(buf, "Legacy | ANT: %s Rate: %s Mbps\n", |
2565 | rs_pretty_ant(ant), iwl_rate_mcs[index].mbps); | 2563 | rs_pretty_ant(ant), |
2564 | index == IWL_RATE_INVALID ? "BAD" : | ||
2565 | iwl_rate_mcs[index].mbps); | ||
2566 | } | 2566 | } |
2567 | 2567 | ||
2568 | if (rate & RATE_MCS_VHT_MSK) { | 2568 | if (rate & RATE_MCS_VHT_MSK) { |