From patchwork Sat Nov 26 16:01:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4707363wrr; Sat, 26 Nov 2022 08:03:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6nd/XgSpVKpIf5vhG40HNJHcvqKxAh+41OVjBz6UXwEE6asxRf93JwZnQCEDk5MREJMlbN X-Received: by 2002:a05:6a00:290f:b0:56b:e15a:7215 with SMTP id cg15-20020a056a00290f00b0056be15a7215mr24074076pfb.27.1669478605257; Sat, 26 Nov 2022 08:03:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478605; cv=none; d=google.com; s=arc-20160816; b=zsmAYr1Nid4ltcYD3ejDRHTWRnXF9FEiCVOeydI2f6tjtCw3uUPMrdkJNSEcbJpI+b zUB93Ldg4W12jN0zdkszD7sBnpsziQ2UpB8FWDdNVBIaovLY8BKFzUi67skcjxxq/jLo cPAja+wvA1Tv36MZQUPQ2vFFmjCZT8so9yk3ZR5LAryNBB7hkDX2MR9Kv9vWCyIHmA+l V1N6ZbyQ5SsaicE1HCFT5ryhCeWLjt+B+IkeeGfACIHv1EOEJFDJGF0WI1h+4JheOIET 6CLFWtBohUX8Fby1RNQkv+f64lfhdcG3RscjU1hBgftT8LiqQxDQ/81zNmJREfnqo+YF zHag== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=G3QpV+uZqky6opfOFJzM1Gt/LBPaaRVvsmp2AJpyE14=; b=ZJKQW4KPaER2xYEBpXAfGre9eAq4JX8L3RhAw4ugKoeXP36i7S1dWH5UM1QaX9WKIs A8zUozct0wxXQawAWKaMRxjoGcMnKo4nE7p4suk6oAZZeuYlKCBlM2TxywEF4RihW18g USzBqFv5sBQnL0dkV4KL2hHUXG4P6zRcBDIN40qvJgIVZ+TlYAKGfIq9Z9roR204tZUE ud/f/AoiPH/64oJIL8zDZLT2ncEYj/SV2pn//8RtWvSv4W0Z80ENMxHyxuQtiGdN+rfB 4Qx7/OOwQATCXeHnIM7ePb1ltBPutHcx/tzQviH6PmFwoUauCeHm1ObF3ZURpMBKT98H OTtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a170902b28b00b00174de06d92csi6542282plr.74.2022.11.26.08.03.11; Sat, 26 Nov 2022 08:03:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbiKZQBm (ORCPT + 99 others); Sat, 26 Nov 2022 11:01:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiKZQBl (ORCPT ); Sat, 26 Nov 2022 11:01:41 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F604193DF for ; Sat, 26 Nov 2022 08:01:40 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxcU-0000Ub-Q4; Sat, 26 Nov 2022 17:01:34 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 01/10] staging: r8188eu: replace one GetAddr3Ptr call Date: Sat, 26 Nov 2022 17:01:20 +0100 Message-Id: <20221126160129.178697-2-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575197753457849?= X-GMAIL-MSGID: =?utf-8?q?1750575197753457849?= Define a struct ieee80211_mgmt in the OnBeacon function. Use it to replace one GetAddr3Ptr call. This is a tiny step towards making GetAddr3Ptr obsolete. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 93696892ec7d..80342b53a129 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -560,6 +560,7 @@ static void OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame) static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) { + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data; int cam_idx; struct sta_info *psta; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -576,7 +577,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) return; } - if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { + if (!memcmp(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { /* we should update current network before auth, or some IE is wrong */ pbss = kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); From patchwork Sat Nov 26 16:01:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4706842wrr; Sat, 26 Nov 2022 08:02:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf7vNtMhPFdjJC3WD/NOUUissuFEPYD/3Ex1cGbSsprkoUfZY3CEFIUKHHuPpsMbDEVRvwbl X-Received: by 2002:a17:902:db09:b0:186:f36a:63b2 with SMTP id m9-20020a170902db0900b00186f36a63b2mr23352054plx.128.1669478565033; Sat, 26 Nov 2022 08:02:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478565; cv=none; d=google.com; s=arc-20160816; b=jyOBXKprsd3oqCtpksJdi3ACIXQR9FvrVApO11KBk3e9eaqOs4GW1GElszRoX06yLv KuLy27L0xmHEJLL1Q9ZYpcOb4f/Bm00mYPYz97zTyJr3CIcntzTSAFFvpGtOAtq0qOa4 +OcoC6CEl60aQpX5o3UIKLY05HLXN8EubXjQ7jHYEIjtXX5gDB2imTlkWB+2rPHZsF5D PmJxUmWNbKEGcHTnsF85mgnARvTK3K4Ua+KUwfT+XH/0G+6QZEWU7XSG1OQRumrUjT5d XcS4POsFINzilI1EFlLhVJm/GZfEkISCxTNOxIroe6TqVyzNhnaaK5M0m50YXZNCIxx/ kRJw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=a9saDzsVzhdECn3lF0EF9IIc/ALNYzSwycl8VLPlYJ4=; b=MYAvUUYAtRbNBNnuHO1Ny0l6R4A5HgrNsOrzDXUvwAKcU2ID2X8KURIdq/809WzU/T 38NBqdLPau9DRVII8CdSyyJv1G7zncTnQyQhY2cEC5ciJy2bR0Bg4GR1/XQd5NLFXQkz IhLmwnvqbVPLo9yDCrXqaArKlRCSakhpF2MW2xePPaaL+8wsC9N6hQtm97OUDiuWq9fs 3E8dLQvOqaDbi7EIrKz1xjGYKFH3uvFIbOXb5lCjetWd+iZl7fuuFYMv/UqUpar3q9oZ KAYs6QNji2wYSoJhUJE4jwRMXnxLnS70HhQ3bPoyg4tXLMvsLVwCsNx/DRndjdMxkg7b AcYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ju12-20020a170903428c00b001892c399db0si6130899plb.363.2022.11.26.08.02.31; Sat, 26 Nov 2022 08:02:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbiKZQBs (ORCPT + 99 others); Sat, 26 Nov 2022 11:01:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiKZQBl (ORCPT ); Sat, 26 Nov 2022 11:01:41 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11593193E2 for ; Sat, 26 Nov 2022 08:01:41 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxcV-0000Ub-Jx; Sat, 26 Nov 2022 17:01:35 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 02/10] staging: r8188eu: read timestamp from ieee80211_mgmt Date: Sat, 26 Nov 2022 17:01:21 +0100 Message-Id: <20221126160129.178697-3-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575156012519993?= X-GMAIL-MSGID: =?utf-8?q?1750575156012519993?= Read the 64-bit timestamp from struct ieee80211_mgmt instead of parsing the beacon message ourselves. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 80342b53a129..66e3a90da3a3 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -389,21 +389,6 @@ static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da) return _SUCCESS; } -static void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe) -{ - u8 *pIE; - __le32 *pbuf; - - pIE = pframe + sizeof(struct ieee80211_hdr_3addr); - pbuf = (__le32 *)pIE; - - pmlmeext->TSFValue = le32_to_cpu(*(pbuf + 1)); - - pmlmeext->TSFValue = pmlmeext->TSFValue << 32; - - pmlmeext->TSFValue |= le32_to_cpu(*pbuf); -} - static void correct_TSF(struct adapter *padapter) { u8 reg; @@ -592,8 +577,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) /* check the vendor of the assoc AP */ pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe + sizeof(struct ieee80211_hdr_3addr), len - sizeof(struct ieee80211_hdr_3addr)); - /* update TSF Value */ - update_TSF(pmlmeext, pframe); + pmlmeext->TSFValue = le64_to_cpu(mgmt->u.beacon.timestamp); /* start auth */ start_clnt_auth(padapter); @@ -635,8 +619,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) return; } - /* update TSF Value */ - update_TSF(pmlmeext, pframe); + pmlmeext->TSFValue = le64_to_cpu(mgmt->u.beacon.timestamp); /* report sta add event */ report_add_sta_event(padapter, GetAddr2Ptr(pframe), cam_idx); From patchwork Sat Nov 26 16:01:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4707559wrr; Sat, 26 Nov 2022 08:03:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf4AvzReZ0gfxWPn8bJ7WEx3/wcYKbQkR/SS+1s82eCewIEdlMbKHvtVRMSCw4Fs1WWeiacw X-Received: by 2002:a17:902:c792:b0:17e:802b:fd6e with SMTP id w18-20020a170902c79200b0017e802bfd6emr24293298pla.116.1669478623556; Sat, 26 Nov 2022 08:03:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478623; cv=none; d=google.com; s=arc-20160816; b=sdOCoktnxv8NuqiiHxp+6JiRUzV08MK96bKM8cTDyNcF8cRsfef9vYErggP8b/WVQu q8eHWKMEKHRaqHw9VKNKPeMoE7oKq+1tDTJESa6+4NMdnVGUcHccfEsb7w+iQboTjbA5 JEVIczZuNwm0gvVGeliYzJ9Sp2FTqvuwO6M8qQo8dwdV6C2bV5jCcJIHmnncBWequPjN OPKGvT1mQqTn8iSfrxngmn3BnvKbzkveBNPqDXZD/nQ9Rupg912X1xtK9a02ryf86mqJ Ds8TdPTZINB5Qor7j9WJx51eyTw/jhPJhDeTcesKQbZWNyRESy4+USnvt8VkRejubMJT Mv0Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mLSzw4tE/eHq4K/DRroyFHvcdMnttCFInfmRZy1f+wQ=; b=zcs4W3b3hm1Y71s3UkY52/GYQeYXVsCzvf/uWsL9m4HvdWX8m2HmOWx8Hc/vZGrFb9 leYtNqqJPi22F1IgZsp4Z62kfnzqutJAOol6jXIYfvEJijyEGCX8opBURwC0lK+R1S3i 9NeI8iDW4wLvWxnxBM2O4AJRe9lJ99cMOx9AHexHLG3Nh2swu4NvGq4v2qF7K4KfFqgi 4ZEWuKAQJrSpBPCMpf0ByV+lOb0mijIHUC9+5MNnd2KsX+rszMIR74PPJuPYd4idZGNL AUK89832zukXzziztXSl/2g3LKZtvOgE4ZADX2cvqtwzHzJEyrqUZwbGrPYdouCOJUoq y38A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e128-20020a636986000000b00476e62744a8si7127939pgc.388.2022.11.26.08.03.29; Sat, 26 Nov 2022 08:03:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbiKZQB4 (ORCPT + 99 others); Sat, 26 Nov 2022 11:01:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbiKZQBm (ORCPT ); Sat, 26 Nov 2022 11:01:42 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 605ED193E0 for ; Sat, 26 Nov 2022 08:01:42 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxcW-0000Ub-D3; Sat, 26 Nov 2022 17:01:36 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 03/10] staging: r8188eu: replace GetAddr2Ptr calls Date: Sat, 26 Nov 2022 17:01:22 +0100 Message-Id: <20221126160129.178697-4-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575217367329697?= X-GMAIL-MSGID: =?utf-8?q?1750575217367329697?= Get the source address of a beacon frame from our struct ieee80211_mgmt instead of using the driver's internal GetAddr2Ptr helper. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 66e3a90da3a3..5a31b20dc46d 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -586,7 +586,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) } if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + psta = rtw_get_stainfo(pstapriv, mgmt->sa); if (psta) { ret = rtw_check_bcn_info(padapter, pframe, len); if (!ret) { @@ -601,7 +601,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) process_p2p_ps_ie(padapter, (pframe + WLAN_HDR_A3_LEN), (len - WLAN_HDR_A3_LEN)); } } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + psta = rtw_get_stainfo(pstapriv, mgmt->sa); if (psta) { /* update WMM, ERP in the beacon */ /* todo: the timer is used instead of the number of the beacon received */ @@ -621,8 +621,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) pmlmeext->TSFValue = le64_to_cpu(mgmt->u.beacon.timestamp); - /* report sta add event */ - report_add_sta_event(padapter, GetAddr2Ptr(pframe), cam_idx); + report_add_sta_event(padapter, mgmt->sa, cam_idx); } } } From patchwork Sat Nov 26 16:01:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4707404wrr; Sat, 26 Nov 2022 08:03:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf4h6/Y96079micUYDWBnFwgEN61UpAkfVwLS/gmRtrcruacFiTu8rCVQi+hDPet3gEPzYo+ X-Received: by 2002:aa7:90c6:0:b0:573:ede1:a46b with SMTP id k6-20020aa790c6000000b00573ede1a46bmr24119938pfk.58.1669478608916; Sat, 26 Nov 2022 08:03:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478608; cv=none; d=google.com; s=arc-20160816; b=umlrW03R0oVB4mefvpz2tlYLHfxyLEe6UEh+O7ndjL/IoSpiBXE+JCzUgCmn+QpDoA DKWKDInirCokEZdA/Fo0WMJDLQVVbLKmgJYX5+j3YlfnkBBMgq8p1TkvKXfUseR2J3oi 5pDCMFZl4C737kl5lTQjn7Q1IuP4U4zvI1PmpVocu4tNtDhH9/WjAUbeze1p3TcntnKq XK9X0HkaLnuvA38C8tmPOQBwaTMssMIK6PUiA2WmSAwOWZ6AK9Zz1wUjuN47LXhxBf4E oVf4/wnUtN8ZAK9YcZiZHxmArJV1cMPZVjop65KsiUGWB8afbsd7kQg4X36K5msRfLDg 8gnw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IW9KhkTJLlniOT4yvR+Ids1+f+EEcE0NQPT/ZTt+sgo=; b=dHQK3ilRZhrRm0GeJ3ekzROJww5LLcr2XMFiKfo9GMoUVWjltu0dWEun5i6Xo3zAty iORMsVtDdMYDIX/X5BcOpVW0oanLoORdg4P7+axZy8j0XUjsbUO5UoS8q4BgxSavYn/y WsWFXKJSb2+UAO14kGEUQCqJxRXNCAamShTBk8s2IF5NiU072iOsHy9v4U/cx6Meg6Db ZgKrSCKC1JWGlFh9qGbxyqAZGLwzvfG8KPwtS4FJwImb1wdYTLEHuCLg06Lw51W8Mr9l gYdME1KduZK6jQZCeK6jWB84JyZK8XZd7kbNjSdvXTncaqZ9fVbVG4PEsVqd+doRzb1I aRwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170902e94500b00186a394aed8si7052912pll.147.2022.11.26.08.03.15; Sat, 26 Nov 2022 08:03:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbiKZQBw (ORCPT + 99 others); Sat, 26 Nov 2022 11:01:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiKZQBm (ORCPT ); Sat, 26 Nov 2022 11:01:42 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14D33193DF for ; Sat, 26 Nov 2022 08:01:41 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxcX-0000Ub-4T; Sat, 26 Nov 2022 17:01:37 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 04/10] staging: r8188eu: pass only ies to process_p2p_ps_ie Date: Sat, 26 Nov 2022 17:01:23 +0100 Message-Id: <20221126160129.178697-5-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575202050650375?= X-GMAIL-MSGID: =?utf-8?q?1750575202050650375?= The process_p2p_ps_ie function parses the information elements of a beacon message and extracts p2p-related info. process_p2p_ps_ie does not receive a pointer to the information elements as one would expect. Instead it receives a pointer to the timestamp field in the beacon message. process_p2p_ps_ie increments this pointer by _BEACON_IE_OFFSET_ to jump to the start of the information elements (and decreases the buffer length accordingly). This is clumsy and hard to understand. Rewrite this such that process_p2p_ps_ie takes a pointer to the information elements and the total length of all elements. Check up-front that the total length is not negative. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 9 ++++++++- drivers/staging/r8188eu/core/rtw_p2p.c | 11 ++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 5a31b20dc46d..07c57a2b61b9 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -556,6 +556,13 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) uint len = precv_frame->len; struct wlan_bssid_ex *pbss; int ret = _SUCCESS; + u8 *ie_ptr; + u32 ie_len; + + ie_ptr = (u8 *)&mgmt->u.beacon.variable; + if (precv_frame->len < offsetof(struct ieee80211_mgmt, u.beacon.variable)) + return; + ie_len = precv_frame->len - offsetof(struct ieee80211_mgmt, u.beacon.variable); if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { report_survey_event(padapter, precv_frame); @@ -598,7 +605,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) /* todo: the timer is used instead of the number of the beacon received */ if ((sta_rx_pkts(psta) & 0xf) == 0) update_beacon_info(padapter, pframe, len, psta); - process_p2p_ps_ie(padapter, (pframe + WLAN_HDR_A3_LEN), (len - WLAN_HDR_A3_LEN)); + process_p2p_ps_ie(padapter, ie_ptr, ie_len); } } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { psta = rtw_get_stainfo(pstapriv, mgmt->sa); diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index dc159e58f428..ce05458bd1ad 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -1505,8 +1505,6 @@ void p2p_protocol_wk_hdl(struct adapter *padapter, int intCmdType) void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) { - u8 *ies; - u32 ies_len; u8 *p2p_ie; u32 p2p_ielen = 0; u8 noa_attr[MAX_P2P_IE_LEN] = { 0x00 };/* NoA length should be n*(13) + 2 */ @@ -1518,13 +1516,8 @@ void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) return; - if (IELength <= _BEACON_IE_OFFSET_) - return; - ies = IEs + _BEACON_IE_OFFSET_; - ies_len = IELength - _BEACON_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); + p2p_ie = rtw_get_p2p_ie(IEs, IELength, NULL, &p2p_ielen); while (p2p_ie) { find_p2p = true; @@ -1579,7 +1572,7 @@ void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) } /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, IELength - (p2p_ie - IEs + p2p_ielen), NULL, &p2p_ielen); } if (find_p2p) { From patchwork Sat Nov 26 16:01:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4707590wrr; Sat, 26 Nov 2022 08:03:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf50sJjkwOfYUB7dGp0yjGERDY1pNIR/6AUGn2N0qxGK4jFWiUhc5lfHNZn8VIEEobbFfzz6 X-Received: by 2002:a63:4c4d:0:b0:46f:8c3a:8b2b with SMTP id m13-20020a634c4d000000b0046f8c3a8b2bmr20813213pgl.477.1669478625882; Sat, 26 Nov 2022 08:03:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478625; cv=none; d=google.com; s=arc-20160816; b=uwRXlF8ff7OhzfqdKhgTOwQ++0wysnTrPBSYJYhvlbIjVFap9+ZVm2lZfnziEnc4Yi 7qj/YrU4ZqykVn2vj2tez5DFycu7fpL/p6ka/pmfje9+JxdMGZP05+z8Ee9dHe58KoeU 7y3sxcjHJy3CWxVSb8g+xonIugsciMu5mIkyLmnePNozjPAs8npJPIbJv6W6A9FvZRyX vgZVNQyFui0T2rKFuJmWxLW5COhDIQixLZbw5FSCHOM27eO/lLPJJdVFCcKwnRjU4OOb vV8dybNoUn7VPpR2vmM63RfMgdOuvR+1P7xDBGnt5gFeQ2TVEJj9XU5t8COm4l/r682h X48Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZhKgV2s4wBGs7W7o2/jt+184AHqAz/iqPFMSAhAt/qc=; b=vhD9in8p4ZeNVhBP218J4rVgSElXWMOAdntFBYJRnvkWSIF28VP1Uk3dfhgyp0FRAJ JVKlsCo8STAlKKziXLqDT28KdC0D7tQ1GwBmPgrRXCYOWXY0AZHR259y5Ec1gnyga49v sEfrJuV070WY0TQg00+LpdIUScZ623E4sOVxsudcwxSZ1vofHEkf50vrRzxol4g2ciy1 nmUuMh9QyHHz7QS+ldQ/EAyoi2wqTl3cS71/+2KI2xop2Lm3KxwR+Dmuxkb1f8RYIcct e4zLPKcP39JRCwu3vBkUKMnJEZW/qt3+bgRN7gWtyUKo6xxXAlpSSd55R+5QTjNv/oAm EzPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6-20020a170902ce8600b001893740c58asi8017785plg.393.2022.11.26.08.03.32; Sat, 26 Nov 2022 08:03:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbiKZQCA (ORCPT + 99 others); Sat, 26 Nov 2022 11:02:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbiKZQBn (ORCPT ); Sat, 26 Nov 2022 11:01:43 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E80FA193DF for ; Sat, 26 Nov 2022 08:01:42 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxcX-0000Ub-Rx; Sat, 26 Nov 2022 17:01:37 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 05/10] staging: r8188eu: use ie buffer in update_beacon_info Date: Sat, 26 Nov 2022 17:01:24 +0100 Message-Id: <20221126160129.178697-6-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575219789441781?= X-GMAIL-MSGID: =?utf-8?q?1750575219789441781?= The update_beacon_info function parses information elements of a beacon message. It should take the pointer to the information elements and their total length, not the entire beacon message. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/r8188eu/core/rtw_wlan_util.c | 9 +++------ drivers/staging/r8188eu/include/rtw_mlme_ext.h | 3 +-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 07c57a2b61b9..38dc98cffbc4 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -604,7 +604,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) /* update WMM, ERP in the beacon */ /* todo: the timer is used instead of the number of the beacon received */ if ((sta_rx_pkts(psta) & 0xf) == 0) - update_beacon_info(padapter, pframe, len, psta); + update_beacon_info(padapter, ie_ptr, ie_len, psta); process_p2p_ps_ie(padapter, ie_ptr, ie_len); } } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { @@ -613,7 +613,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) /* update WMM, ERP in the beacon */ /* todo: the timer is used instead of the number of the beacon received */ if ((sta_rx_pkts(psta) & 0xf) == 0) - update_beacon_info(padapter, pframe, len, psta); + update_beacon_info(padapter, ie_ptr, ie_len, psta); } else { /* allocate a new CAM entry for IBSS station */ cam_idx = allocate_fw_sta_entry(padapter); diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 965bb7da4cce..da3465d6bb0f 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -1035,16 +1035,13 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) return _FAIL; } -void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, struct sta_info *psta) +void update_beacon_info(struct adapter *padapter, u8 *ie_ptr, uint ie_len, struct sta_info *psta) { unsigned int i; - unsigned int len; struct ndis_802_11_var_ie *pIE; - len = pkt_len - (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN); - - for (i = 0; i < len;) { - pIE = (struct ndis_802_11_var_ie *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i); + for (i = 0; i < ie_len;) { + pIE = (struct ndis_802_11_var_ie *)(ie_ptr + i); switch (pIE->ElementID) { case _HT_EXTRA_INFO_IE_: /* HT info */ diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h index 089bd5446773..6724424a334e 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h @@ -447,8 +447,7 @@ void HTOnAssocRsp(struct adapter *padapter); void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); void VCS_update(struct adapter *padapter, struct sta_info *psta); -void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, - struct sta_info *psta); +void update_beacon_info(struct adapter *padapter, u8 *ie_ptr, uint ie_len, struct sta_info *psta); int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len); void update_IOT_info(struct adapter *padapter); void update_capinfo(struct adapter *adapter, u16 updatecap); From patchwork Sat Nov 26 16:01:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4707778wrr; Sat, 26 Nov 2022 08:04:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf60qQzU7KtWIfbA/HqC+O5W9JEF1sT0n2jarjFWtLY6vd+ywTpCQFNo0Gf2uK9Ug09PU4H7 X-Received: by 2002:a63:1a48:0:b0:477:786:f557 with SMTP id a8-20020a631a48000000b004770786f557mr21484323pgm.476.1669478639733; Sat, 26 Nov 2022 08:03:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478639; cv=none; d=google.com; s=arc-20160816; b=ilGWgCiojHmATywpihXpegxAusGsx0b3Z2bthCGzD8TLv10J6U+/QikLUTAXLJRxFM LN1ShBc3QlU0fkC3aHNztaBY5atgFyF7PXXJ24mgtVBVk55Nk0dh0NoPErPxhziTJnOp bPqYMCz3A2maRIdU/8n7T//Uu6CVcILJ9df0UkWET0obZR1lkiOXkFdHUhTAMJVmkbRv 9TpgTDoDtYBKlzNJ2L/sU+T++Ty1egaRojL2zis6xJJNZ5DLTAceTsGDbSC3Q9GNcCSA giwCMgJs+ZAD9QF0JUZYZu2o3o+l0+urAPL8zX+L5YfRDldz0r0xAuyFsN6AiZUwCbB+ EG6A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZNT/djaKtegO85izbz5C4xLiq4K3i2xWDr56ic48Nrs=; b=gpTiPIPg2ywmZBhwa/bBJho1wni4wM3T4BPMKzBTVXO4n4dpBbjDWcRSndDDQl+qQH vjZBWLGzyhzjyE6ppGnExT3hWSGB2okoATkDcInj7k+ioJBKxpGIlkySEe8qlmv9RscM GhVdsw6SG/pzNwctUVMkiGJqAxKobpIzcYQjz85fgKgbzO/1zzC2+HJsW+eN1sqdPRiz 59pkhlxWB6wO8E6bCX3oV/hs+mGIPJ3OaZN+R3zHZIBOAd2Mi78CIUuiL503sY9aJz5G sgx9Ws3MX9eO1YJqYmpkvrUAlFd5g2TGLe8UScykMuR8c7UQf/Q0NJwBNWVT56HJ+6+q YcOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i64-20020a638743000000b004767bc4252csi6915365pge.519.2022.11.26.08.03.46; Sat, 26 Nov 2022 08:03:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbiKZQCG (ORCPT + 99 others); Sat, 26 Nov 2022 11:02:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbiKZQBo (ORCPT ); Sat, 26 Nov 2022 11:01:44 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34AB8193F0 for ; Sat, 26 Nov 2022 08:01:43 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxcY-0000Ub-JA; Sat, 26 Nov 2022 17:01:38 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 06/10] staging: r8188eu: simplify update_sta_support_rate params Date: Sat, 26 Nov 2022 17:01:25 +0100 Message-Id: <20221126160129.178697-7-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575234240820409?= X-GMAIL-MSGID: =?utf-8?q?1750575234240820409?= The update_sta_support_rate function takes a pointer to information elements and the total length of all these elements. Use our variables for pointer and length instead of calculating them manually. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 38dc98cffbc4..f7d3ecf551bf 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -621,7 +621,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) return; /* get supported rate */ - if (update_sta_support_rate(padapter, (pframe + WLAN_HDR_A3_LEN + _BEACON_IE_OFFSET_), (len - WLAN_HDR_A3_LEN - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) { + if (update_sta_support_rate(padapter, ie_ptr, ie_len, cam_idx) == _FAIL) { pmlmeinfo->FW_sta_info[cam_idx].status = 0; return; } From patchwork Sat Nov 26 16:01:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26266 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4707714wrr; Sat, 26 Nov 2022 08:03:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf4mJtY0x4y7CWtsi+pssrSOS6531l+GhqLapq1aW7NzY89I81pUeFEWXg7u8NQY9CBLNUjQ X-Received: by 2002:a63:e404:0:b0:477:f6be:b65b with SMTP id a4-20020a63e404000000b00477f6beb65bmr3616400pgi.362.1669478635618; Sat, 26 Nov 2022 08:03:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478635; cv=none; d=google.com; s=arc-20160816; b=NfGXQjSHHctbHiu8Nz3wL7Ju+l6GWKg+sDTzh4HQmPK4I5zboyYOfTdwlbKLhhvPpn RqcofkACy4T3AbKcwW6AVmDbKcZMlH/nRAbbmyY3UxjZd8ADE18+rsCPSf2INuinbGQO 7Wzwzxzyj/X5dm8eT9ehEpCcs7gxmrePV3Tm+hpv6Igu0tM9rWHpbS6zlDVQzKkjVkO7 6R1TqdLpeeUBa7/+i976USKffEt9/ShkCsS9rGtyQt6nqgZnxUmg/p2RAJ3K/7+G0HC6 EZOo3uKG1NWUnjjkSLv+zqvDYgWWQAekLtpLnzUzu2MGpjsKO9cpye239+hd1JPjJWjk 4mZQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=brCvKDqn7RI/0atmgzU7xozp/5rAV/FtVFI/p11e/ms=; b=K+FfnrxGFhqVPUC8S3+VWTBZGrK50kZ3oMpYt8uZuJPEULiS8Sv+CYd2HZbM5iAUmX POyxprjjiJ1G588qiF8Hpnf7i5PDGFRcME1ywLsnG4yGtPtCfQmCT4RNYnf8Hx0IOPO1 sVY2oaCMhXR1vVR+McZxC/kQ96EnR+mxUjaSi+ITYfG8KSzDOCyOLtHBQtAeq904qXdR mDHxDSQ/2DYoUsDWXXwt6PTJtdGypCLNYP9p+nkHdK2Hjf2PPWPIOmvTpGjYv6TXZ8rE h7lbSWxQBEgzjppZ/BfWKl7dVRltnaEVB1bWvj/eQPtzekQecIzT8o623bNDO85hVIG9 4wjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a170902f7c400b0016be68156aesi6574242plw.173.2022.11.26.08.03.42; Sat, 26 Nov 2022 08:03:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbiKZQCD (ORCPT + 99 others); Sat, 26 Nov 2022 11:02:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbiKZQBo (ORCPT ); Sat, 26 Nov 2022 11:01:44 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F31E6193ED for ; Sat, 26 Nov 2022 08:01:43 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxcZ-0000Ub-AR; Sat, 26 Nov 2022 17:01:39 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 07/10] staging: r8188eu: exit if beacon is not from our bss Date: Sat, 26 Nov 2022 17:01:26 +0100 Message-Id: <20221126160129.178697-8-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575230136772157?= X-GMAIL-MSGID: =?utf-8?q?1750575230136772157?= Do not process an incoming beacon message in the OnBeacon function if the beacon was sent by a base station other than the one to which we're connected. This patch does not modify the behaviour of the code. It reverts the if condition and returns if the beacon should not be processed. This is simpler than wrapping the entire processing into a large if clause. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 103 ++++++++++---------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index f7d3ecf551bf..a15998d912a7 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -569,67 +569,68 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) return; } - if (!memcmp(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { - if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { - /* we should update current network before auth, or some IE is wrong */ - pbss = kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); - if (pbss) { - if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { - update_network(&pmlmepriv->cur_network.network, pbss, padapter, true); - rtw_get_bcn_info(&pmlmepriv->cur_network); - } - kfree(pbss); + if (memcmp(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) + return; + + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + /* we should update current network before auth, or some IE is wrong */ + pbss = kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); + if (pbss) { + if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { + update_network(&pmlmepriv->cur_network.network, pbss, padapter, true); + rtw_get_bcn_info(&pmlmepriv->cur_network); } + kfree(pbss); + } - /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe + sizeof(struct ieee80211_hdr_3addr), len - sizeof(struct ieee80211_hdr_3addr)); + /* check the vendor of the assoc AP */ + pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe + sizeof(struct ieee80211_hdr_3addr), len - sizeof(struct ieee80211_hdr_3addr)); - pmlmeext->TSFValue = le64_to_cpu(mgmt->u.beacon.timestamp); + pmlmeext->TSFValue = le64_to_cpu(mgmt->u.beacon.timestamp); - /* start auth */ - start_clnt_auth(padapter); + /* start auth */ + start_clnt_auth(padapter); - return; - } + return; + } - if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { - psta = rtw_get_stainfo(pstapriv, mgmt->sa); - if (psta) { - ret = rtw_check_bcn_info(padapter, pframe, len); - if (!ret) { - receive_disconnect(padapter, - pmlmeinfo->network.MacAddress, 0); - return; - } - /* update WMM, ERP in the beacon */ - /* todo: the timer is used instead of the number of the beacon received */ - if ((sta_rx_pkts(psta) & 0xf) == 0) - update_beacon_info(padapter, ie_ptr, ie_len, psta); - process_p2p_ps_ie(padapter, ie_ptr, ie_len); + if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { + psta = rtw_get_stainfo(pstapriv, mgmt->sa); + if (psta) { + ret = rtw_check_bcn_info(padapter, pframe, len); + if (!ret) { + receive_disconnect(padapter, + pmlmeinfo->network.MacAddress, 0); + return; } - } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { - psta = rtw_get_stainfo(pstapriv, mgmt->sa); - if (psta) { - /* update WMM, ERP in the beacon */ - /* todo: the timer is used instead of the number of the beacon received */ - if ((sta_rx_pkts(psta) & 0xf) == 0) - update_beacon_info(padapter, ie_ptr, ie_len, psta); - } else { - /* allocate a new CAM entry for IBSS station */ - cam_idx = allocate_fw_sta_entry(padapter); - if (cam_idx == NUM_STA) - return; + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) + update_beacon_info(padapter, ie_ptr, ie_len, psta); + process_p2p_ps_ie(padapter, ie_ptr, ie_len); + } + } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { + psta = rtw_get_stainfo(pstapriv, mgmt->sa); + if (psta) { + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) + update_beacon_info(padapter, ie_ptr, ie_len, psta); + } else { + /* allocate a new CAM entry for IBSS station */ + cam_idx = allocate_fw_sta_entry(padapter); + if (cam_idx == NUM_STA) + return; - /* get supported rate */ - if (update_sta_support_rate(padapter, ie_ptr, ie_len, cam_idx) == _FAIL) { - pmlmeinfo->FW_sta_info[cam_idx].status = 0; - return; - } + /* get supported rate */ + if (update_sta_support_rate(padapter, ie_ptr, ie_len, cam_idx) == _FAIL) { + pmlmeinfo->FW_sta_info[cam_idx].status = 0; + return; + } - pmlmeext->TSFValue = le64_to_cpu(mgmt->u.beacon.timestamp); + pmlmeext->TSFValue = le64_to_cpu(mgmt->u.beacon.timestamp); - report_add_sta_event(padapter, mgmt->sa, cam_idx); - } + report_add_sta_event(padapter, mgmt->sa, cam_idx); } } } From patchwork Sat Nov 26 16:01:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4707829wrr; Sat, 26 Nov 2022 08:04:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf6lJduVjuFP7a8e2M6asbf9BsSfBGLMXNN3q15Uh0R/fp7Ka4CPB23/e8SjohHi9SWpPIQn X-Received: by 2002:aa7:851a:0:b0:56c:b679:bf6d with SMTP id v26-20020aa7851a000000b0056cb679bf6dmr44763863pfn.13.1669478642517; Sat, 26 Nov 2022 08:04:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478642; cv=none; d=google.com; s=arc-20160816; b=iJwt42X6At58Nx7sQ2Qr1I3sfLcjK7k1AbTYKxMCi7WzE7uxvciQj7hGZA8O2J+mLl FNXigTsg9bpL9j8Is+y9oSJUJmjqda+vus8UOZ//BDSOSivCvUNFxIHFykn7sNDULeUu 89uM3an6oEBVUZsR5qBBL6ffrIl5Y2BxyWkZG54RKAkiz6i4ZzvzGqHINCZOuJsGWyU3 fy693O4w5cy9E3Mxk0NizGV2SV3xAuEUUnYaJOFwAr/Lm4bVofqT8011u294UQWZ0esf V4aQNht47t8vknPhS881o0IRIKlFTsE+R21z26i8T0aAZIhe6F625lbAjHkuGegPMRpe Nr5w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1/sDCNpJgApNKSt8RsPP0ovLtlq46ONCw3xg00fmIh0=; b=InbZVz+X5JNRMGWCw8TgKAKHuEjqX6ioiGbplqAD21rNdLmZGboozYYYwSo67QV4HF 2AJDL/eWEHOif4jt0KSVVM95jtei86ouyV+TsqEjOACCEg5aDYrf65kX14yVpLpWbKUQ FFapbYDmFn8xLbM3uDfCkh9LRxu030YK9q2rgGzFbrrNdyvGSVVfFWrxZFOryDUbmsgX X9c+uyshKZSbev4aEWxDU+mlwlDkWcSbx5AD4Fu8l9czTK2VZ/LDs8GikLNr51cr44ID ZEeMCQZPQmjxZ2o84pZKgOigxIjzGGiwdMHvaV7XNUn5eSTw2D8uIV/EFSbibmTwhFPv 1plw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020a170902a61100b00186f9d4400esi6731602plq.346.2022.11.26.08.03.49; Sat, 26 Nov 2022 08:04:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229737AbiKZQCL (ORCPT + 99 others); Sat, 26 Nov 2022 11:02:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbiKZQBr (ORCPT ); Sat, 26 Nov 2022 11:01:47 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2157A193ED for ; Sat, 26 Nov 2022 08:01:46 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxca-0000Ub-21; Sat, 26 Nov 2022 17:01:40 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 08/10] staging: r8188eu: stop beacon processing if kmalloc fails Date: Sat, 26 Nov 2022 17:01:27 +0100 Message-Id: <20221126160129.178697-9-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575237192758822?= X-GMAIL-MSGID: =?utf-8?q?1750575237192758822?= If we cannot allocate a struct wlan_bssid_ex in the OnBeacon function, we should stop processing the incoming beacon message and return. For kmalloc failures, the current code just skips the update of network and beacon info and tries to continue with the authentication. The update would set the encryption algorithm that should be used for the authentication. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index a15998d912a7..76424bcba416 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -575,13 +575,14 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { /* we should update current network before auth, or some IE is wrong */ pbss = kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); - if (pbss) { - if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { - update_network(&pmlmepriv->cur_network.network, pbss, padapter, true); - rtw_get_bcn_info(&pmlmepriv->cur_network); - } - kfree(pbss); + if (!pbss) + return; + + if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { + update_network(&pmlmepriv->cur_network.network, pbss, padapter, true); + rtw_get_bcn_info(&pmlmepriv->cur_network); } + kfree(pbss); /* check the vendor of the assoc AP */ pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe + sizeof(struct ieee80211_hdr_3addr), len - sizeof(struct ieee80211_hdr_3addr)); From patchwork Sat Nov 26 16:01:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4707809wrr; Sat, 26 Nov 2022 08:04:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf64Bsm4ZK54wTkXSdyQ15b8/V1wc8bAhMANpLn1uL/rasecdFgcTuJPBQ2iZgToECm2PgWY X-Received: by 2002:a17:902:e809:b0:186:8518:6c95 with SMTP id u9-20020a170902e80900b0018685186c95mr24502922plg.149.1669478641431; Sat, 26 Nov 2022 08:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478641; cv=none; d=google.com; s=arc-20160816; b=EHcT0TdSU/n7BBxkB6j15mnEr4ddVY1+w2egDNQcBTBu/Zc5Yd05jcSu3u6SbYYh+K eerr1OXWs/96XhZ7OKDnMBB6A+RSWs83taJ1A+UmkwZeh83wngMWywql2eHAdN4lpGMQ sIgL61Q1nateSFbS5KixXVCgMlAVM6etfueXLkTbptHvqk951OeT9lGUHlGRn4GyAiCG CYmlpHv/A63T9+PM2bMPo8vDNxuC3a/mt14ugjiQmsAqMfP456whqGGqm3+byTbjmLCC y4HHeOnw/70wLlgK/JdDxt84kDbbVqgmZYRAvJ6eVJ8QnltIwKKv1QXiowz0EKf5X0+r +/+g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=A0A0SHvSoIv0chB+0jYBCrTPGOsQtpeMgolenbhc0tI=; b=b9SJC26RmSrHUZGLU78WoNy4ZhykE/WklMx8xcUfX5iD82Qeg9Nv0GGaOhYwQuYMOc bzZx4VBxRrVu5q1p5W+hMG/V9H70C4p/YHSPLLqUyVLuX44E/nOFZvQCqzC7zS4IHbDL DvYsrKN6q0WG8vUW4nqcoIeIj0p3JjR7XPUn3S1QiuTW8ZLBl0fanbzA5ePnjuwb67ta oVREqqmjug5BlSfwxAeh/WAxKRraAc2qjOmyL54QXTrgEHOgIphUGEjZyJeth0I/8ReZ nrKAYay+SATeOA8tQd4dxB9Y+Q3YQaQPTghZXlsBFOzGM0r9GVjRtLIOVL7vG1Gdd1of D1Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d24-20020a17090ac25800b00212fb7e54ddsi6405883pjx.81.2022.11.26.08.03.48; Sat, 26 Nov 2022 08:04:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229624AbiKZQCJ (ORCPT + 99 others); Sat, 26 Nov 2022 11:02:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiKZQBr (ORCPT ); Sat, 26 Nov 2022 11:01:47 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E635193F8 for ; Sat, 26 Nov 2022 08:01:46 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxca-0000Ub-Q7; Sat, 26 Nov 2022 17:01:40 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 09/10] staging: r8188eu: simplify error handling for missing station Date: Sat, 26 Nov 2022 17:01:28 +0100 Message-Id: <20221126160129.178697-10-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575236154870461?= X-GMAIL-MSGID: =?utf-8?q?1750575236154870461?= Simplify the code to handle the case where we're associated to a station that is not in our list of known stations. We can simply exit in this case. This patch reverts the if-condition and saves one level of indentation. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 76424bcba416..362313c49c52 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -597,19 +597,19 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { psta = rtw_get_stainfo(pstapriv, mgmt->sa); - if (psta) { - ret = rtw_check_bcn_info(padapter, pframe, len); - if (!ret) { - receive_disconnect(padapter, - pmlmeinfo->network.MacAddress, 0); - return; - } - /* update WMM, ERP in the beacon */ - /* todo: the timer is used instead of the number of the beacon received */ - if ((sta_rx_pkts(psta) & 0xf) == 0) - update_beacon_info(padapter, ie_ptr, ie_len, psta); - process_p2p_ps_ie(padapter, ie_ptr, ie_len); + if (!psta) + return; + + ret = rtw_check_bcn_info(padapter, pframe, len); + if (!ret) { + receive_disconnect(padapter, pmlmeinfo->network.MacAddress, 0); + return; } + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) + update_beacon_info(padapter, ie_ptr, ie_len, psta); + process_p2p_ps_ie(padapter, ie_ptr, ie_len); } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { psta = rtw_get_stainfo(pstapriv, mgmt->sa); if (psta) { From patchwork Sat Nov 26 16:01:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 26270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4708115wrr; Sat, 26 Nov 2022 08:04:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf4c5zWbq7FsSSm9eMQdwCYGSDSlFckA2MQ36ad6+iUunu+SfYXWJ+41KkkVY0YdrP08Lf45 X-Received: by 2002:a17:902:e849:b0:17a:aca0:e295 with SMTP id t9-20020a170902e84900b0017aaca0e295mr37154157plg.3.1669478665513; Sat, 26 Nov 2022 08:04:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669478665; cv=none; d=google.com; s=arc-20160816; b=SL2yjGZNNnvFb1V+JxXF4XgbpQVV83kXD4KlHynVHQQKeKVf1+mj/0rdmQH+pWY4UJ NLBmnAu1rGkBaFVpY/MlLBumKxGOEs5jQIMr/FgGSc9c/PHNnQlawo1cICkqbVnFwEKh 7NZbcjP4Qce9NJCB5y3AcMeUiI/u9aw2P8geUXv2LUSQcpqjouro3kQLAgLOvtbZtns/ dEX/LmbPxiwIWwT+c+MKV1qWuzkUVYk6kHT4V7WZ4/djx49f9es8pcJCAkOHviZvyQEL IwXjRe+p4gPjJpkUh40YfGLVajJbZ9Q8EtCYF4x6bVsErbZPPfO3iWJ1rLMrpkIRwO6f aPwQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kEJ/Eto1jkEe3z/2uFBgrwi3wSk7Uh+sVn1GH7LWE/4=; b=sR+DJ+8DVX3lJnzHrGB+7SCcFRhQJHOVSosvlTy2mozK6NC9ceBYYbyjZiFy/6u3LA jRC8lWviRaXIckQ0fM9tcmUSwrPh1n2pUN/B9QG5ZyNRijbsWorRRzcZtpxvQiWnerAd riPSB7LpBdX4E7i6mlkNJtqtG3n46b/NSdX+RTBx6zQAfDQlryg3m6h0pcONhQ/R232z 08m3kQgcAm13hFPKa9qOcDzR/oibvuHnvQmnj/gmbm0Qtr9Goav63079aVZn7d+ltmsb i9JCiVKddTWyoZ35l3vAsLLi3QHM0DJ01jSbembupwBA7DIaEKzzpN4Ic5BhtGHVeoZ0 Rzzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a17090300c500b0018875900d97si6206639plc.20.2022.11.26.08.04.11; Sat, 26 Nov 2022 08:04:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbiKZQCP (ORCPT + 99 others); Sat, 26 Nov 2022 11:02:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbiKZQBs (ORCPT ); Sat, 26 Nov 2022 11:01:48 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B81D5193FB for ; Sat, 26 Nov 2022 08:01:47 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxcb-0000Ub-K2; Sat, 26 Nov 2022 17:01:41 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 10/10] staging: r8188eu: remove a variable Date: Sat, 26 Nov 2022 17:01:29 +0100 Message-Id: <20221126160129.178697-11-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750575261053302964?= X-GMAIL-MSGID: =?utf-8?q?1750575261053302964?= Check the result of rtw_check_bcn_info directly and remove the ret variable. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 362313c49c52..d32b2d569e23 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -555,7 +555,6 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) u8 *pframe = precv_frame->rx_data; uint len = precv_frame->len; struct wlan_bssid_ex *pbss; - int ret = _SUCCESS; u8 *ie_ptr; u32 ie_len; @@ -600,8 +599,7 @@ static void OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) if (!psta) return; - ret = rtw_check_bcn_info(padapter, pframe, len); - if (!ret) { + if (rtw_check_bcn_info(padapter, pframe, len) != _SUCCESS) { receive_disconnect(padapter, pmlmeinfo->network.MacAddress, 0); return; }