Skip to content

Commit

Permalink
iwlegacy: 4965-rs: avoid null pointer dereference error
Browse files Browse the repository at this point in the history
il4965_rs_initialize_lq checks to see if sta is null, however, before that
check il4965_rs_use_green dereferences sta when intializing use_green.
Avoid a potential null pointer dereference error by only calling
il4965_rs_use_green after we are sure sta is not null.

Smatch analysis:

drivers/net/wireless/iwlegacy/4965-rs.c:2160 il4965_rs_initialize_lq() warn:
  variable dereferenced before check 'sta' (see line 2155)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Colin Ian King authored and John W. Linville committed Mar 27, 2013
1 parent 7fc0357 commit ace5af3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/wireless/iwlegacy/4965-rs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2152,14 +2152,15 @@ il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf,
int rate_idx;
int i;
u32 rate;
u8 use_green = il4965_rs_use_green(il, sta);
u8 use_green;
u8 active_tbl = 0;
u8 valid_tx_ant;
struct il_station_priv *sta_priv;

if (!sta || !lq_sta)
return;

use_green = il4965_rs_use_green(il, sta);
sta_priv = (void *)sta->drv_priv;

i = lq_sta->last_txrate_idx;
Expand Down

0 comments on commit ace5af3

Please sign in to comment.