Skip to content

Commit

Permalink
NET: ath5k, check ath5k_eeprom_mode_from_channel retval
Browse files Browse the repository at this point in the history
It can, if invalid argument given, return a negative value. In that
case we would access arrays out-of-bounds and such. Check the value
and yell loudly if that happened as it would be a bug in the
implementation. (Instead of silently corrupting memory.)

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Nick Kossifidis <mickflemm@gmail.com>
Cc: "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Jiri Slaby authored and John W. Linville committed Feb 8, 2013
1 parent 957f4ac commit c5e534e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/net/wireless/ath/ath5k/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,10 @@ ath5k_hw_update_noise_floor(struct ath5k_hw *ah)
ah->ah_cal_mask |= AR5K_CALIBRATION_NF;

ee_mode = ath5k_eeprom_mode_from_channel(ah->ah_current_channel);
if (WARN_ON(ee_mode < 0)) {
ah->ah_cal_mask &= ~AR5K_CALIBRATION_NF;
return;
}

/* completed NF calibration, test threshold */
nf = ath5k_hw_read_measured_noise_floor(ah);
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/wireless/ath/ath5k/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,8 @@ ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah,
return;

ee_mode = ath5k_eeprom_mode_from_channel(channel);
if (WARN_ON(ee_mode < 0))
return;

/* Adjust power delta for channel 14 */
if (channel->center_freq == 2484)
Expand Down

0 comments on commit c5e534e

Please sign in to comment.