Skip to content

Commit

Permalink
net: wireless: ath9k: avoid possible NULL pointer dereference
Browse files Browse the repository at this point in the history
Code in ath9k_hw_set_clockrate function indicates that ah->curchan
(and thus chan local variable) may be NULL.  If that is indeed the
case, IS_CHAN_HT40(chan) check has to be performed only in branch
where chan is not NULL.  Moving the code under already existing
if condition fixes this issue.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Michal Nazarewicz authored and John W. Linville committed Dec 2, 2013
1 parent a1783a7 commit beae416
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/net/wireless/ath/ath9k/hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ static void ath9k_hw_set_clockrate(struct ath_hw *ah)
else
clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM;

if (IS_CHAN_HT40(chan))
clockrate *= 2;

if (ah->curchan) {
if (chan) {
if (IS_CHAN_HT40(chan))
clockrate *= 2;
if (IS_CHAN_HALF_RATE(chan))
clockrate /= 2;
if (IS_CHAN_QUARTER_RATE(chan))
Expand Down

0 comments on commit beae416

Please sign in to comment.