From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B91DFEEB566 for ; Fri, 8 Sep 2023 18:14:23 +0000 (UTC) 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:References:In-Reply-To: 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: List-Owner; bh=b1HOHd88fyihliqcl3GSP2HskDPeiHOoVYt86z895Dg=; b=ExMbuRTzRqnZu8 ToPlnssdA8h5YdIt7zPU8r1kOvtLvx8A2G7WNNNf5OG4VZcIu3M1Isv0n/yqNRiO/n0EqbV+c+r6p O4TZqm0CvgIGbsZVoQ+KCxdULUN2i/tGXOvA7zCTR+7NEVJas4UwlHvgENze4uLKpbt2k6nZYST1o 42bFf/1Emtp6D2MXwGFx+j1lALY/zXlGfNCwsHZus+nJcWB1hs3G5BiU3PJ6MhkD4f3sfl8fUxL78 HXzkZtTwz/q79O8q2jrHio4aZzJPQuSg8yZoBX+0W+hgXfI5RZjF23sjjvKN2ndqiDMAlANixWwQo qsYAZqBvrIVCMOMr5ufw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qefzr-00EEh7-1X for ath12k@archiver.kernel.org; Fri, 08 Sep 2023 18:14:23 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qefzo-00EEfr-2I for ath12k@lists.infradead.org; Fri, 08 Sep 2023 18:14:22 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id B44C6CE1C49; Fri, 8 Sep 2023 18:14:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5AB7C4160E; Fri, 8 Sep 2023 18:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694196857; bh=C/oZWkbGa1eucFDmpYfjnG4KHf6jX8KutakSwJRZLDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ciVSDDfWE2BV+DVuIv4VCiy+CIbtAFAHZl1HNxVx774/N251D5wMeVnWZhF+Au8CN x1c/aLdfNaauys2W0XYF8cioKWVnH/AzJ5LoI0ifIVjCUYy0EwEftcToc7jWy0UdTK LmmO+TPEMbkNJcnYyZDTJfMKQtpPpD3HJE/99wDvuFDinDxdbjWNYQJsvwJdtIB2X0 6FI9sn1MgjigB0Hkzh4G2E4QAl+MSV7RbnRFLbgrI9lQx6YQh7K13Vi71erbVPwTE3 ETrgtjwITwIutR68Fb9tsomn5EjuHzJF8ylDgllX1x/zc1iQnBr7TMo2VuZpbVHhqQ h3uodLzILPGxA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wen Gong , Kalle Valo , Sasha Levin , kvalo@kernel.org, quic_jjohnson@quicinc.com, ath12k@lists.infradead.org, linux-wireless@vger.kernel.org Subject: [PATCH AUTOSEL 6.5 17/45] wifi: ath12k: avoid array overflow of hw mode for preferred_hw_mode Date: Fri, 8 Sep 2023 14:12:58 -0400 Message-Id: <20230908181327.3459042-17-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230908181327.3459042-1-sashal@kernel.org> References: <20230908181327.3459042-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230908_111421_110396_6DF7A063 X-CRM114-Status: GOOD ( 12.02 ) X-BeenThere: ath12k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "ath12k" Errors-To: ath12k-bounces+ath12k=archiver.kernel.org@lists.infradead.org From: Wen Gong [ Upstream commit 1e9b1363e2de1552ee4e3d74ac8bb43a194f1cb4 ] Currently ath12k define WMI_HOST_HW_MODE_DBS_OR_SBS=5 as max hw mode for enum wmi_host_hw_mode_config_type, it is also same for the array ath12k_hw_mode_pri_map. When tested with new version firmware/board data which support new hw mode eMLSR mode with hw mode value 8, it leads overflow usage for array ath12k_hw_mode_pri_map in function ath12k_wmi_hw_mode_caps(), and then lead preferred_hw_mode changed to 8, and finally function ath12k_pull_mac_phy_cap_svc_ready_ext() select the capability of hw mode 8, but the capability of eMLSR mode report from firmware does not support 2.4 GHz band for WCN7850, so finally 2.4 GHz band is disabled. Skip the hw mode which exceeds WMI_HOST_HW_MODE_MAX in function ath12k_wmi_hw_mode_caps() helps to avoid array overflow, then the 2.4 GHz band will not be disabled. This is to keep compatibility with newer version firmware/board data files, this change is still needed after ath12k add eMLSR hw mode 8 in array ath12k_hw_mode_pri_map and enum wmi_host_hw_mode_config_type, because more hw mode maybe added in next firmware/board data version e.g hw mode 9, then it will also lead new array overflow without this change. Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4 Signed-off-by: Wen Gong Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20230714072405.28705-1-quic_wgong@quicinc.com Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath12k/wmi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c index 4928e4e916603..4f378f06e946e 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.c +++ b/drivers/net/wireless/ath/ath12k/wmi.c @@ -3704,6 +3704,10 @@ static int ath12k_wmi_hw_mode_caps(struct ath12k_base *soc, for (i = 0 ; i < svc_rdy_ext->n_hw_mode_caps; i++) { hw_mode_caps = &svc_rdy_ext->hw_mode_caps[i]; mode = le32_to_cpu(hw_mode_caps->hw_mode_id); + + if (mode >= WMI_HOST_HW_MODE_MAX) + continue; + pref = soc->wmi_ab.preferred_hw_mode; if (ath12k_hw_mode_pri_map[mode] < ath12k_hw_mode_pri_map[pref]) { -- 2.40.1 -- ath12k mailing list ath12k@lists.infradead.org https://lists.infradead.org/mailman/listinfo/ath12k