提交 8b783d10 编写于 作者: T Thomas Pedersen 提交者: Johannes Berg

mac80211: handle lack of sband->bitrates in rates

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: NThomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20201005164522.18069-1-thomas@adapt-ip.comSigned-off-by: NJohannes Berg <johannes.berg@intel.com>
上级 9faebeb2
...@@ -709,7 +709,8 @@ void sta_set_rate_info_tx(struct sta_info *sta, ...@@ -709,7 +709,8 @@ void sta_set_rate_info_tx(struct sta_info *sta,
u16 brate; u16 brate;
sband = ieee80211_get_sband(sta->sdata); sband = ieee80211_get_sband(sta->sdata);
if (sband) { WARN_ON_ONCE(sband && !sband->bitrates);
if (sband && sband->bitrates) {
brate = sband->bitrates[rate->idx].bitrate; brate = sband->bitrates[rate->idx].bitrate;
rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
} }
......
...@@ -2122,6 +2122,10 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u32 rate, ...@@ -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); int rate_idx = STA_STATS_GET(LEGACY_IDX, rate);
sband = local->hw.wiphy->bands[band]; sband = local->hw.wiphy->bands[band];
if (WARN_ON_ONCE(!sband->bitrates))
break;
brate = sband->bitrates[rate_idx].bitrate; brate = sband->bitrates[rate_idx].bitrate;
if (rinfo->bw == RATE_INFO_BW_5) if (rinfo->bw == RATE_INFO_BW_5)
shift = 2; shift = 2;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册