Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3614365pxb; Sun, 31 Jan 2021 23:12:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJ9tkUV8n351zcmNzlygNo2G29/7r5pEDWcCbgpM0RNwWupfTb086/OACgdjUB2SfOZfUh X-Received: by 2002:a17:906:f0c4:: with SMTP id dk4mr4317700ejb.6.1612163530084; Sun, 31 Jan 2021 23:12:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612163530; cv=none; d=google.com; s=arc-20160816; b=GVXvgObcKsTvsQ8y9g3Yodw5vcnXroCa3TvBE7L6qr9XMXdl+docuMUcEvNytBHe3k mwX+5aLWDZPaT6yFp/7ioBfhXlhNjnF9TnP4q7hRdkjw10j6ORDLuIvFp4LpHV+RZD/5 NGDqLy/dHskORFlKTrWkifKPwI5ykKp48/PmA5nfKxO7TMd6ll1z3aIQhgXVsRdCq7Gw WACDSfRnGH2qKp2m0260EYx2ab8UTk/exTJipFNJkBXqNTqmnYWnvq+A671VO3X89o7G H6Qq27qxfJhTi/UWnsRfaMFoUDNT37YNxmkLklEgn1zZA2wY89uH6abB+uenKgA3iork c9Tg== 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=yEAXr+uYT47arw+BgtSxxjuiMvD2994EjnVkSqzNVfY=; b=jYld3i5gyRMyQtAKswJWNucWWbR/yK85xC4wnFyrbB2iGcO90VrCVxwNXUJ4YBFkHx hNBf/tXpXxhvQF1kpwAh7Wt+35CcxxcKw8RxzBa4XeRRTz6B/fW1Du7IHxhyima+YtCA NvdJ+hV7U9W5ARbMbQC+rZ4Hg54RIGeGZUbasLAn34D0GnAVAlqZVxVNMGnFyAGnAjXM diWejZwtZKe+6FP2RrqUBKgxXkLEBnLnxqnzlwqymOCpazxFbWCiw3Dw5DpKTP9f1ZSa JW4X+TUK3ROuT5R6/4lr7EU5ntgIqrITsi5g6/GOxb+1REU1dVHUN6T2+PksX8kMbGCT FVEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W57OCjk6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ws14si10223995ejb.625.2021.01.31.23.11.46; Sun, 31 Jan 2021 23:12:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W57OCjk6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231864AbhBAHKR (ORCPT + 99 others); Mon, 1 Feb 2021 02:10:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232397AbhBAHH5 (ORCPT ); Mon, 1 Feb 2021 02:07:57 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E97EC061756 for ; Sun, 31 Jan 2021 23:07:17 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id my11so9123161pjb.1 for ; Sun, 31 Jan 2021 23:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yEAXr+uYT47arw+BgtSxxjuiMvD2994EjnVkSqzNVfY=; b=W57OCjk6JbbEC4TjR83KofLCibS8dcJom3IZSNhSRjw5CSmPK6uBlvGID5M8peSK1g qbg2aSsCsVu9ARLEz506EijrXcJ5cuXfR7bEvPEGoLV1lckL1uC9baxQJI3Vvx2z3tj0 cyXH9yc3PwbWbOlLXj4Lhsj8YujMnzZQTFyj8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yEAXr+uYT47arw+BgtSxxjuiMvD2994EjnVkSqzNVfY=; b=YdBhdgMpC/sci3oj24GhCqc+irDGO7b6pNKev/H0aIqW4sKzqdDY2+Pa5R8VDSiPKr eK4PRxLg8UzK4R04swNnf5LZaJSP+k05lpN4aNDoqN9RCQYvOkHjF+OO6AxAKahPpdJX ZRg97YIlSDYwoDOXXb6bOg5XIYv2nVX6Gb99X5oI0/sVnlDBbfcGQSU94a7LYgyVC+Ff T7QeH1GF53H2bc2JdddpV0+R8N5+l9+y3r78ZyXFXQDTcGS3GZ3sPI6WjFj+MhpluY54 JJ9gzim9frkq3a3CGMVZrQwz3qHfHSm2J/sLtJNDFGUmb7Ozzn2TODUJzv7lg8Kcy+zO V7Sw== X-Gm-Message-State: AOAM533VsS3aAV9fXMFHkC/iRFUEkajQ6YyLGKOU3MZsRqn3nv06kAfi VGHXyvxA1vVh42uMAJgBs+zcHA== X-Received: by 2002:a17:90a:b282:: with SMTP id c2mr16030435pjr.54.1612163236914; Sun, 31 Jan 2021 23:07:16 -0800 (PST) Received: from localhost ([2401:fa00:1:b:158e:ed37:38d6:db19]) by smtp.gmail.com with ESMTPSA id a22sm14306240pjh.5.2021.01.31.23.07.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 31 Jan 2021 23:07:16 -0800 (PST) From: Yen-lin Lai To: linux-wireless@vger.kernel.org Cc: Brian Norris , Yen-lin Lai , Amitkumar Karwar , "David S. Miller" , Ganapathi Bhat , Jakub Kicinski , Kalle Valo , Xinming Hu , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] mwifiex: Report connected BSS with cfg80211_connect_bss() Date: Mon, 1 Feb 2021 15:06:49 +0800 Message-Id: <20210201070649.1667209-1-yenlinlai@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a network is moved or reconfigured on the different channel, there can be multiple BSSes with the same BSSID and SSID in scan result before the old one expires. Then, it can cause cfg80211_connect_result to map current_bss to a bss with the wrong channel. Let mwifiex_cfg80211_assoc return the selected BSS and then the caller can report it cfg80211_connect_bss. Signed-off-by: Yen-lin Lai --- .../net/wireless/marvell/mwifiex/cfg80211.c | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index a6b9dc6700b1..4bae83e47e9e 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -2173,7 +2173,8 @@ static int mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, const u8 *ssid, const u8 *bssid, int mode, struct ieee80211_channel *channel, - struct cfg80211_connect_params *sme, bool privacy) + struct cfg80211_connect_params *sme, bool privacy, + struct cfg80211_bss **sel_bss) { struct cfg80211_ssid req_ssid; int ret, auth_type = 0; @@ -2307,17 +2308,31 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, } } + if (bss) + cfg80211_ref_bss(priv->adapter->wiphy, bss); + ret = mwifiex_bss_start(priv, bss, &req_ssid); if (ret) - return ret; + goto cleanup; if (mode == NL80211_IFTYPE_ADHOC) { /* Inform the BSS information to kernel, otherwise * kernel will give a panic after successful assoc */ - if (mwifiex_cfg80211_inform_ibss_bss(priv)) - return -EFAULT; + if (mwifiex_cfg80211_inform_ibss_bss(priv)) { + ret = -EFAULT; + goto cleanup; + } } + /* Pass the selected BSS entry to caller. */ + if (sel_bss) { + *sel_bss = bss; + bss = NULL; + } + +cleanup: + if (bss) + cfg80211_put_bss(priv->adapter->wiphy, bss); return ret; } @@ -2334,6 +2349,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, { struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); struct mwifiex_adapter *adapter = priv->adapter; + struct cfg80211_bss *bss = NULL; int ret; if (GET_BSS_ROLE(priv) != MWIFIEX_BSS_ROLE_STA) { @@ -2369,11 +2385,12 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy, 0); ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid, - priv->bss_mode, sme->channel, sme, 0); + priv->bss_mode, sme->channel, sme, 0, + &bss); if (!ret) { - cfg80211_connect_result(priv->netdev, priv->cfg_bssid, NULL, 0, - NULL, 0, WLAN_STATUS_SUCCESS, - GFP_KERNEL); + cfg80211_connect_bss(priv->netdev, priv->cfg_bssid, bss, NULL, + 0, NULL, 0, WLAN_STATUS_SUCCESS, + GFP_KERNEL, NL80211_TIMEOUT_UNSPECIFIED); mwifiex_dbg(priv->adapter, MSG, "info: associated to bssid %pM successfully\n", priv->cfg_bssid); @@ -2504,7 +2521,7 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, ret = mwifiex_cfg80211_assoc(priv, params->ssid_len, params->ssid, params->bssid, priv->bss_mode, params->chandef.chan, NULL, - params->privacy); + params->privacy, NULL); done: if (!ret) { cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid, -- 2.30.0.365.g02bc693789-goog