From patchwork Tue Aug 17 15:11:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 12441619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 571E5C4338F for ; Tue, 17 Aug 2021 15:11:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 209CB60524 for ; Tue, 17 Aug 2021 15:11:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 209CB60524 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jaMAvhXFXK+Utpu/KMgUzmj0Fy4PTBRLpqrtFriemf8=; b=YCDL6nngXVsWcV hSfCKUoC7enKWP+25F2WMtSI0DuE8SMxAw879/a+6OCqwGpCw4PaMCORVr16G/7W+cIpnhAsRtoqj pId+jeY7l1AXrM96ZDgflbKqV7BZI8VeMioqcyTbE8Prw75kuxWHzn1jjfK9ujYXuusGQAyMrID0K VnzGfQlZ4vI+5MCDCyiOqHim5dg96qXKmIOgGkYHkwVw31s6aMsv37dLVWyud7JATCk6mad23zhva 8JpWH5KvGwGLqP0K42JvJtrMwShbtsJZtXFh3eiyRXovAfe/ZEBuAVEZ/VulwkIRBejAmUlkfUAPw C7rtPmCpaORGvGkfVU3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mG0kX-002lya-LV; Tue, 17 Aug 2021 15:11:33 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mG0kR-002lvs-2k for linux-mediatek@lists.infradead.org; Tue, 17 Aug 2021 15:11:32 +0000 X-UUID: 97c3b105c18742b49d90b914f68614e0-20210817 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=GScf8q3jXeR5itaZaTOWdDIwXzMXwBcCpCKrXXVlyOA=; b=AgojzycDCw9kLFt/+DmFuuh4KS5ADz/yyCdqDcX2+uD0zIXjumZAyyH2bTZXbabJZ8pKvyhQkoxCfyqKWVraKgZyAjJ2fHmPdQ4ctNjp/6nbETdurwWG4T7cNW6BF7dWcBRCzR/yNSrlsPdi270NGaYlHRAjQEvm1z6255Wh4Ug=; X-UUID: 97c3b105c18742b49d90b914f68614e0-20210817 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1511933220; Tue, 17 Aug 2021 08:11:23 -0700 Received: from mtkmbs05n2.mediatek.inc (172.21.101.140) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 17 Aug 2021 08:11:21 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 17 Aug 2021 23:11:20 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 17 Aug 2021 23:11:20 +0800 From: Ryder Lee To: Felix Fietkau CC: Lorenzo Bianconi , Shayne Chen , Evelyn Tsai , , , "Ryder Lee" Subject: [PATCH] mt76: add a bound check in mt76_calculate_default_rate() Date: Tue, 17 Aug 2021 23:11:19 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210817_081128_594171_F5D56C33 X-CRM114-Status: UNSURE ( 9.03 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org basic_rate could be 0 ie. hidden AP. Always pick the lowest rate for such cases. Fixes: 75fb2e62d444 (mt76: add mt76_default_basic_rate more devices can rely on) Signed-off-by: Ryder Lee --- drivers/net/wireless/mediatek/mt76/mac80211.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index e282c627e25c..3658328f513b 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -1360,6 +1360,10 @@ u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx) if (phy->chandef.chan->band == NL80211_BAND_5GHZ) offset = 4; + /* pick the lowest rate for hidden nodes */ + if (rateidx < 0) + rateidx = 0; + rate = &mt76_rates[offset + rateidx]; return rate->hw_value;