Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3445306pxk; Mon, 5 Oct 2020 09:48:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd2RaruG8wAp9GP5ysSjdfOrcp/o7YevzhQexxI4+TffiBp3QMTA4jxJ0NBeGQFBasKkGo X-Received: by 2002:a17:906:c78a:: with SMTP id cw10mr640455ejb.478.1601916517897; Mon, 05 Oct 2020 09:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601916517; cv=none; d=google.com; s=arc-20160816; b=MdPqELFk9Ur9m4hUEEJ6LG7QLsWiLG8c0iu8ALFDhBK1dagb/4KiUj6pP6mZf6Ek51 rkCKU9lqIXM1lX8irLu0hUwXHGDhI5sYHzG3Y7e835Zkp4FUod4kfcmI7Tp1pOXF5cgI bU3DaKpi/6DlhK6Xu2BCvSxauV0ahWl1bt6z3ZBcJf+lo7bkqs6XLBW8aBvqeA8DUxAU lGWC4G0KrFTU1yiLMDdX9Qc0g5k1lGHkJ1sRw7G06H4fZtNJkoZqodTH7J10BheAca0v +r2A/Bzb8apzmsx9Jc30aP/y/+H91Nmwe2ErGgB+plei3KnTKzMgds2ZoKYziQYmdUyo KiCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=NsaAJ/PNnEV/MjOWtl8rDDS0Gev3GHXDQv7/ppdMRVE=; b=RG+M0vO3t6HEv224kiLPrhmSZMGs9rWp2rP8sMFD8RqLDJw8pIsumGY1JmRDRq398Z ISVWs9KpRA+7wOSj7l65cyckrd5SNGEXmMIRhJX/0Cuvii1VlFntir2FMG/By1T8njfB QsoxYmfgxU8jaQjNIlgFK7CGRzU4VaDDBl3TRv0u8ww/H2K25JHUtLg1huMqvEJuEdmA l4cNaMCtSdSayjpkTTUZvnFEK3HpORhFvp/q94r7aeZ0PhfvuXlpTBL3oLHKj+EeoEYs l4FqQlYM8SqZ3ZF91g1Nq48GEwdqTZT4cRPlYK5dAepHE45cW2W5sOyDcL/0m0REIa48 HlbA== 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 p11si410953edj.203.2020.10.05.09.48.12; Mon, 05 Oct 2020 09:48:37 -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 S1727110AbgJEQpY (ORCPT + 99 others); Mon, 5 Oct 2020 12:45:24 -0400 Received: from mail.adapt-ip.com ([173.164.178.19]:36750 "EHLO web.adapt-ip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726659AbgJEQpX (ORCPT ); Mon, 5 Oct 2020 12:45:23 -0400 Received: from localhost (localhost [127.0.0.1]) by web.adapt-ip.com (Postfix) with ESMTP id 4DA964FA159; Mon, 5 Oct 2020 16:45:23 +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 RxlxJbMEwkPj; Mon, 5 Oct 2020 16:45:20 +0000 (UTC) Received: from atlas.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 6EDAF4FA158; Mon, 5 Oct 2020 16:45:20 +0000 (UTC) From: Thomas Pedersen To: Johannes Berg Cc: linux-wireless , Thomas Pedersen Subject: [PATCH v2 1/2] mac80211: handle lack of sband->bitrates in rates Date: Mon, 5 Oct 2020 09:45:21 -0700 Message-Id: <20201005164522.18069-1-thomas@adapt-ip.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 --- v2: WARN_ON -> WARN_ON_ONCE (Ben) --- 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..eb52aafd9381 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_ONCE(sband && !sband->bitrates); + 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..fb4f2b9b294f 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_ONCE(!sband->bitrates)) + break; + brate = sband->bitrates[rate_idx].bitrate; if (rinfo->bw == RATE_INFO_BW_5) shift = 2; -- 2.20.1