]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mac80211: handle lack of sband->bitrates in rates
authorThomas Pedersen <thomas@adapt-ip.com>
Mon, 5 Oct 2020 16:45:21 +0000 (09:45 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:12:12 +0000 (10:12 +0100)
[ Upstream commit 8b783d104e7f40684333d2ec155fac39219beb2f ]

Even though a driver or mac80211 shouldn't produce a
legacy bitrate if sband->bitrates doesn't exist, don't
crash if that is the case either.

This fixes a kernel panic if station dump is run before
last_rate can be updated with a data frame when
sband->bitrates is missing (eg. in S1G bands).

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20201005164522.18069-1-thomas@adapt-ip.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/mac80211/cfg.c
net/mac80211/sta_info.c

index 87fddd84c621ef3da18a5c6e48c434fb43dfc5ee..82d516d117385f9305075fefb6163451f353b017 100644 (file)
@@ -709,7 +709,8 @@ void sta_set_rate_info_tx(struct sta_info *sta,
                u16 brate;
 
                sband = ieee80211_get_sband(sta->sdata);
-               if (sband) {
+               WARN_ON_ONCE(sband && !sband->bitrates);
+               if (sband && sband->bitrates) {
                        brate = sband->bitrates[rate->idx].bitrate;
                        rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
                }
index f2840d1d95cfbf4a038cbf5d380e07f8102d2cd2..fb4f2b9b294f03cc3aa28dbf2f5d11e78c0936a0 100644 (file)
@@ -2122,6 +2122,10 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u32 rate,
                int rate_idx = STA_STATS_GET(LEGACY_IDX, rate);
 
                sband = local->hw.wiphy->bands[band];
+
+               if (WARN_ON_ONCE(!sband->bitrates))
+                       break;
+
                brate = sband->bitrates[rate_idx].bitrate;
                if (rinfo->bw == RATE_INFO_BW_5)
                        shift = 2;