mac80211: pid, fix memory corruption
authorJiri Slaby <jirislaby@gmail.com>
Wed, 13 May 2009 07:55:26 +0000 (09:55 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 12 Jun 2009 03:01:36 +0000 (20:01 -0700)
commit00d025abdfdcc686052ed1d9c25f10ead680e620
treef84edb060e80080b054bcdd9e53fdb91201b5f2d
parentedafc7a273c17f4806fd785c2fb0574161e8dcf5
mac80211: pid, fix memory corruption

commit a8659597bf744b0f8d2560e2a734b5c941569e0e upstream

pid doesn't count with some band having more bitrates than the one
associated the first time.
Fix that by counting the maximal available bitrate count and allocate
big enough space.

Secondly, fix touching uninitialized memory which causes panics.
Index sucked from this random memory points to the hell.
The fix is to sort the rates on each band change.

Also remove a comment which is wrong now.

This version also contains half of
mac80211: avoid NULL ptr deref when finding max_rates in PID and minstrel
patch by John W. Linville, which is namely:
-               if (sband->n_bitrates > max_rates)
+               if (sband && sband->n_bitrates > max_rates)
to fix oopses on one band devices.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/mac80211/rc80211_pid_algo.c