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));