>From aeca211f0bb6186eefb7f3a6ad98115e2256e53a Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Aug 2013 12:34:45 +0200 Subject: [PATCH] brcmsmac: avoid kernel panic due to divide-by-zero error The patch avoid the kernel panic and adds a few error log messages. Signed-off-by: Arend van Spriel --- drivers/net/wireless/brcm80211/brcmsmac/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 9fd6f2f..ea92ea2 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -630,10 +630,21 @@ static uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, dur = PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); if (preamble_type == BRCMS_MM_PREAMBLE) dur += PREN_MM_EXT; + + if (mcs > BRCMS_MAXMCS) { + brcms_err(wlc->hw->d11core, "wl%d: invalid mcs: %u\n", + wlc->pub->unit, mcs); + mcs = 0; + } /* 1000Ndbps = kbps * 4 */ kNdps = mcs_2_rate(mcs, rspec_is40mhz(ratespec), rspec_issgi(ratespec)) * 4; + if (kNdps == 0) { + brcms_err(wlc->hw->d11core, "wl%d: invalid zero rate: rspec=0x%x\n", + wlc->pub->unit, ratespec); + kNdps = 6500 * 4; + } if (rspec_stc(ratespec) == 0) nsyms = CEIL((APHY_SERVICE_NBITS + 8 * mac_len + -- 1.7.10.4