mac80211: avoid NULL ptr deref when finding max_rates in PID and minstrel

"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>

+2 -2
+1 -1
net/mac80211/rc80211_minstrel.c
··· 477 477 478 478 for (i = 0; i < IEEE80211_NUM_BANDS; i++) { 479 479 sband = hw->wiphy->bands[i]; 480 - if (sband->n_bitrates > max_rates) 480 + if (sband && sband->n_bitrates > max_rates) 481 481 max_rates = sband->n_bitrates; 482 482 } 483 483
+1 -1
net/mac80211/rc80211_pid_algo.c
··· 378 378 379 379 for (i = 0; i < IEEE80211_NUM_BANDS; i++) { 380 380 sband = hw->wiphy->bands[i]; 381 - if (sband->n_bitrates > max_rates) 381 + if (sband && sband->n_bitrates > max_rates) 382 382 max_rates = sband->n_bitrates; 383 383 } 384 384