Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1591053pxk; Fri, 2 Oct 2020 13:40:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzu68I3cT9LfRhH1BnrFyZL56rjjw8VgRGzfw25tZ3thiMdryU8dvwY4vFNbhBq1mvXGf92 X-Received: by 2002:a17:906:8695:: with SMTP id g21mr3934260ejx.504.1601671200725; Fri, 02 Oct 2020 13:40:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601671200; cv=none; d=google.com; s=arc-20160816; b=cc1nXwrxeJAOHxoAHrrDZhh5QYBNb3MMcFzsFIfoTks1nmYUca4ICTe1LNRyu0sdu5 364kBIqceZ+dDFW49uSivbrdeLMVtu79i3fZ/DPnDGRPr15B3cCK0L17/p4/fgJ7XnTX NwHlADXernRHIQnvSpMPjjqylI3DfLBIwsnsmkjSM4Wrknar00BA8OnMFEUDRBBh6NnE IAJCJOlmK1uEfFY71MNhVpHsu2dAnX1MKM/0LafyC7jXjiu+z+B9TMPidPl+GPlfVerd T9dMobDPLvBLli567qHhedwbvdftp9a8MqYnz3owWX25w1G2xAdQtgmFfRZ23pxW5AXu OfpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version; bh=1AJUOtH9JxMt1lXp/WhXlQjkY1VrmDY/xIROumhzRfA=; b=YCyo/wAhGQSVb/e1owzEQoi87W2Wy+SZWfPtkCikcLR8/yfCbIpl9NNQERZw4gAUp/ MhC6ERL6gTHdEIyGOCRJ2HFVuxEmNEw+t3/TglEd+f9T0106hcZ2O6V18ulN59iXNin8 jTafY85bjC8Gic/MfZ6n+07NllFjPJ57kQSwlVWLpP+wSpJ19ZAWQIlPc9xO5NPsMzpU g0Ho/9nULZHAHnjhdaLsvKN8szaiWweF9MGmKUKh5V8u9EGyU9xwKb+v+q+PoOJAopm1 jGII/iGnm8Ik+M6c2DWKn/Bd2pFxEQTF4LJaIliflRuh37cIKEiNeKDOT/LMhjK5TUvO wlnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc17si2091193edb.261.2020.10.02.13.39.23; Fri, 02 Oct 2020 13:40:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725681AbgJBUjI (ORCPT + 99 others); Fri, 2 Oct 2020 16:39:08 -0400 Received: from mail.adapt-ip.com ([173.164.178.19]:55464 "EHLO web.adapt-ip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725283AbgJBUjI (ORCPT ); Fri, 2 Oct 2020 16:39:08 -0400 Received: from localhost (localhost [127.0.0.1]) by web.adapt-ip.com (Postfix) with ESMTP id D37394FA0E0; Fri, 2 Oct 2020 20:39:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at web.adapt-ip.com Received: from web.adapt-ip.com ([127.0.0.1]) by localhost (web.adapt-ip.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id sAQOFNHcOvsl; Fri, 2 Oct 2020 20:39:05 +0000 (UTC) Received: from mail.ibsgaard.io (c-73-223-60-234.hsd1.ca.comcast.net [73.223.60.234]) (Authenticated sender: thomas@adapt-ip.com) by web.adapt-ip.com (Postfix) with ESMTPSA id D2C7C4FA0C5; Fri, 2 Oct 2020 20:39:04 +0000 (UTC) MIME-Version: 1.0 Date: Fri, 02 Oct 2020 13:39:04 -0700 From: Thomas Pedersen To: Ben Greear Cc: Johannes Berg , linux-wireless Subject: Re: [PATCH 1/2] mac80211: handle lack of sband->bitrates in rates In-Reply-To: References: <20201002175308.16374-1-thomas@adapt-ip.com> User-Agent: Roundcube Webmail/1.4.7 Message-ID: <58e16c9d04eb12fcd817027bde2b6769@adapt-ip.com> X-Sender: thomas@adapt-ip.com Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2020-10-02 11:55, Ben Greear wrote: > On 10/2/20 10:53 AM, Thomas Pedersen wrote: >> 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 >> --- >> net/mac80211/cfg.c | 3 ++- >> net/mac80211/sta_info.c | 4 ++++ >> 2 files changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c >> index da70f174d629..e40160114824 100644 >> --- a/net/mac80211/cfg.c >> +++ b/net/mac80211/cfg.c >> @@ -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(sband && !sband->bitrates); > > Maybe WARN_ON_ONCE to keep the spam down in case this is hit repeatedly > for some reason? Thanks, I originally had it as WARN_ON_ONCE(), then changed it. Not sure why, I don't feel strongly about it either way :) I'll make them both WARN_ON_ONCE(). > >> + if (sband && sband->bitrates) { >> brate = sband->bitrates[rate->idx].bitrate; >> rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); >> } >> diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c >> index f2840d1d95cf..0efb66b8f185 100644 >> --- a/net/mac80211/sta_info.c >> +++ b/net/mac80211/sta_info.c >> @@ -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(!sband->bitrates)) >> + break; >> + >> brate = sband->bitrates[rate_idx].bitrate; >> if (rinfo->bw == RATE_INFO_BW_5) >> shift = 2; >> -- thomas