Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1292713pxb; Tue, 17 Aug 2021 08:16:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8SQlU3E9Zn3rX5bjB0CGwcwmhuBsNXsOUcvIKhNbmBtYpfrkbsz8iQAUkGmRN2+YwfwAZ X-Received: by 2002:a17:906:5855:: with SMTP id h21mr4424396ejs.230.1629213419005; Tue, 17 Aug 2021 08:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629213418; cv=none; d=google.com; s=arc-20160816; b=c7qerhZxdeEeO3Cyv2O96zVeOOVx/hQuO7f/U2i8YiP3dYVo/1D+4HMQvig53o7z/E PEKK1gCRAC7tAcrRfVQuJTOaCQOc0Kk4tz+8P5Ztpw3tbsyrKursx3d3yIqpNacIzYY5 azjKUzpnlgscxmoTyodci+BkSsvJWRtE/FrHVWrVN12ILWUEipPApgHhVsWO3B6FtvXN Z5rsyzS4cQX26H/JD+WGorG/nWvWEavZJ3e6j8KY4yNMnT7+BYEs5Cv25GYTUnK+05fS e90o0UR5c4M+R+aKa/G4ABbzRf7U7gdC4xMcaNxwEKULlWXy793+tPiAp98mGNStQuwF c4AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=ssJbgw2A6gqwR5QIYFjreg3/hcvDdmNYWV6x0Q6axPM=; b=idA+Sz+lOJxfXf6ytEIgncjgmavEASlLACD5nLNvDL8oaF7pocna0G3PyFBS6u8ABp khPAbuyckt8ySU43gfvS03fM1s0umfNjO8w9Q3c7Does++kvq1QiB4lvbUdK1WfTHbX6 To1WAyGYXukTOuH5MvRllQzEU+T4Hmy4coqW55v+YyuRvd2SoVWBgmLVOafdNvcKdEwf 3+lnk2v3ePbdrQ9Y0kvTMMxP9woEGjl6lkqkCZNDw4AuWnSyD3PdLQgp9G83GjwRe+ub FmjrdpkE9SNznLjE38eVtE+gQCzrZcgTLCVFzVLVu1s32XhJ5gqFdec49Z+6EHiYA8rJ qy0A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si2931879edv.199.2021.08.17.08.16.26; Tue, 17 Aug 2021 08:16:58 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240082AbhHQPMB (ORCPT + 99 others); Tue, 17 Aug 2021 11:12:01 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:37390 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S238352AbhHQPL7 (ORCPT ); Tue, 17 Aug 2021 11:11:59 -0400 X-UUID: 69980d906f934727937951f5759e81df-20210817 X-UUID: 69980d906f934727937951f5759e81df-20210817 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1465298048; Tue, 17 Aug 2021 23:11:21 +0800 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 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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; -- 2.29.2