Skip to content

Commit

Permalink
mac80211: avoid NULL ptr deref when finding max_rates in PID and mins…
Browse files Browse the repository at this point in the history
…trel

"There is another problem with this piece of code. The sband will be NULL
after second iteration on single band device and cause null pointer
dereference. Everything is working with dual band card. Sorry, but i
don't know how to explain this clearly in English. I have looked on the
second patch for pid algorithm and found similar bug."

Reported-by: Karol Szuster <qflon@o2.pl>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
John W. Linville committed May 11, 2009
1 parent aedec92 commit 621ad7c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion net/mac80211/rc80211_minstrel.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ minstrel_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)

for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
sband = hw->wiphy->bands[i];
if (sband->n_bitrates > max_rates)
if (sband && sband->n_bitrates > max_rates)
max_rates = sband->n_bitrates;
}

Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/rc80211_pid_algo.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static void *rate_control_pid_alloc(struct ieee80211_hw *hw,

for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
sband = hw->wiphy->bands[i];
if (sband->n_bitrates > max_rates)
if (sband && sband->n_bitrates > max_rates)
max_rates = sband->n_bitrates;
}

Expand Down

0 comments on commit 621ad7c

Please sign in to comment.