Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2125881rwp; Fri, 14 Jul 2023 00:48:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlHfuNaNkh7XhSDejXghDzY72KcrIG1bRh9O0T142KS/WePVs9e7GenK38fZIqkRv6HfykMA X-Received: by 2002:ac2:4e05:0:b0:4f8:7513:8cac with SMTP id e5-20020ac24e05000000b004f875138cacmr3396465lfr.48.1689320914423; Fri, 14 Jul 2023 00:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689320914; cv=none; d=google.com; s=arc-20160816; b=foNMOgRugjwKUznOmo9uUtEZyULlx97prMaY9viwhewLATHFSB9JmtmxBwbMDArIwG 5fHU9Vp/jdq1TjX8W8fFyKcsRm2O7b4T9oSHbhWyJ2L3UkUGVnGaeCd0UZvJhTakfk2L aGkiyIHqGA0IwqjKIktZah8AJetzp2azz4FiyLforRNRwoH+9b/l9FpFl0kgieco6YGA Kz4mRHtS8hTCXBVWQV7+Rv1YgGLZhx23zk6svva8UPC6cSXuXEVhkgSb6tgF4i6EdiIz vZPNlc3s86zYKTN302tueKPq5bJwK1COdqR6lCy/uzLqR54+PqLf6lGN8ZYp3Us1pPzn 2E6Q== 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:dkim-signature; bh=Cjw8DDFVhCw353h6rtzIrzrDq3pD+EchseT4VKpq1/g=; fh=239N9TPK33Qn7ha+Q0sQ3fNhJmIROSC7xWfxOgJDZ+k=; b=hIC1ANRhtYhzSLh2dkvadBLmKSFbeeIXygluk19n3YrMw0KYA+MG9CecuXGyoZxyID m3S2wHXs16DfI3CBcKQweF7mLrJT/erWS9dZe3oH6v6nK/KlmyMAGGA+gcIFfV1FUudP 7p2HZTqwYlJjwtGGoKc91fHga+FWjsFQ8RZxhS346Ukgy/ojTAVh1oulmrWJuGVUeaip BW+6SOLVyW3Xmmr3uhzUkOA3n7zfhnb/5UYtUDbyBC39oT5e1sP4NYAX1TAaqwqYAjS4 no79O/YsAbWCEiLtKjbxhrsrxqlD+1yFF8AEz07q1c5OyOtR8ETy3/JKoQIbY4EH3oJh TcVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=j89tohQH; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f24-20020a05640214d800b0051be9317ccasi8891147edx.508.2023.07.14.00.48.18; Fri, 14 Jul 2023 00:48:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=j89tohQH; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231864AbjGNHYg (ORCPT + 59 others); Fri, 14 Jul 2023 03:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbjGNHYf (ORCPT ); Fri, 14 Jul 2023 03:24:35 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54D2AC0 for ; Fri, 14 Jul 2023 00:24:34 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36E6Gm7O029335; Fri, 14 Jul 2023 07:24:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=Cjw8DDFVhCw353h6rtzIrzrDq3pD+EchseT4VKpq1/g=; b=j89tohQH+Yfkpjj6QfOeNmXOpHoAE2Ln72/luaviVXCvmLyds9wpqJGaYQxbEYDjACwj wBecFGpHLyaOW69UEBe4NIYUpR2jmD8xO3t+yuNzaersRilb2L+SXNasvPEunvHmq/K/ rGDMc8fS2aE5Gl7pZEflmhgZwM83Eal/BcdiiEGKz7mspMfY0cVytn3D6YTuZhUTd/HX 4KzS5p8zSROAPmCs4HVgdMvylFBgaT9k9lUDvtVDmumNbT5Xn4bX6acgm9ySIXs7jNwk j4tGIJNd9DWpFXdc9EsvBxsQ+mR5E+XdFPsPP2jDTmFwg8xh57u9Jfx1PBHkOzchMT4X Gg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rtpuks4hb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Jul 2023 07:24:27 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36E7OQ4I000683 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Jul 2023 07:24:26 GMT Received: from wgong-HP3-Z230-SFF-Workstation.qca.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Fri, 14 Jul 2023 00:24:24 -0700 From: Wen Gong To: CC: , Subject: [PATCH] wifi: ath12k: avoid array overflow of hw mode for preferred_hw_mode Date: Fri, 14 Jul 2023 03:24:05 -0400 Message-ID: <20230714072405.28705-1-quic_wgong@quicinc.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: U_9-BpAinQg7BRMhm4LgufR1pWoG5B7M X-Proofpoint-GUID: U_9-BpAinQg7BRMhm4LgufR1pWoG5B7M X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_04,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1011 bulkscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140067 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 --- 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 7ae0bb78b2b5..cef01148fc16 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.c +++ b/drivers/net/wireless/ath/ath12k/wmi.c @@ -3701,6 +3701,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]) { base-commit: 0a00db612b6df1fad80485e3642529d1f28ea084 -- 2.40.1