From patchwork Sun Dec 1 07:31:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Roy, UjjaL" X-Patchwork-Id: 3261721 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 57DC7BEEAD for ; Sun, 1 Dec 2013 07:31:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48DDF2047C for ; Sun, 1 Dec 2013 07:31:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CDEB2016C for ; Sun, 1 Dec 2013 07:31:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751394Ab3LAHbo (ORCPT ); Sun, 1 Dec 2013 02:31:44 -0500 Received: from mail-pb0-f49.google.com ([209.85.160.49]:35650 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751387Ab3LAHbn (ORCPT ); Sun, 1 Dec 2013 02:31:43 -0500 Received: by mail-pb0-f49.google.com with SMTP id jt11so16822193pbb.22 for ; Sat, 30 Nov 2013 23:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Rqt5bYtqig42WuzBWDTEHtf2qlWQy5nllg2lKcz1Mko=; b=TJGaU3pMkbECqBTDqsOhbcfOr6+a0spPiJRHTOGetBw/RiMI2Vlk+GnrJKrJPXkr4a cDYJ7vXEYbFCcyeS3++X3g9/arAEqmINRn7xMEs7IY3GRpDL61rAHy0qrCU7UDaaZ2Li ypVYukYJBbp7hBKWkutvr2Mov/+NppnmB8b0Q7d4ohhhrGlRh32AH+yIekH+nsR7sEIb aXmmIs9xKjT1uZB9d5Iciw7u2qsAX9GMdUIB2G4kJD4JmLIPG2ku/Dt3Gs+XnjI3cjSN hfnap/EnTqynzJMeJfDbboFmsvZ3ajcOLQAi6pl5145CdMKY5EFpOsBJVjMn/svJjLUT pIuA== X-Received: by 10.66.146.170 with SMTP id td10mr77686pab.161.1385883102943; Sat, 30 Nov 2013 23:31:42 -0800 (PST) Received: from localhost.local.lan ([117.194.248.138]) by mx.google.com with ESMTPSA id hu10sm113710127pbc.11.2013.11.30.23.31.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Nov 2013 23:31:42 -0800 (PST) From: Ujjal Roy To: "John W. Linville" Cc: , Johannes Berg Subject: [PATCH] cfg80211: fix WARN_ON for re-association to the expired BSS Date: Sun, 1 Dec 2013 13:01:36 +0530 Message-Id: <1385883096-7143-1-git-send-email-royujjal@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP cfg80211 allows re-association in managed mode and if a user wants to re-associate to the same AP network after the time period of IEEE80211_SCAN_RESULT_EXPIRE, cfg80211 warns with the following message on receiving the connect result event. ------------[ cut here ]------------ WARNING: CPU: 0 PID: 13984 at net/wireless/sme.c:658 __cfg80211_connect_result+0x3a6/0x3e0 [cfg80211]() Call Trace: [] dump_stack+0x46/0x58 [] warn_slowpath_common+0x87/0xb0 [] warn_slowpath_null+0x15/0x20 [] __cfg80211_connect_result+0x3a6/0x3e0 [cfg80211] [] ? update_rq_clock+0x2b/0x50 [] ? update_curr+0x1/0x160 [] cfg80211_process_wdev_events+0xb2/0x1c0 [cfg80211] [] ? pick_next_task_fair+0x63/0x170 [] cfg80211_process_rdev_events+0x38/0x90 [cfg80211] [] cfg80211_event_work+0x1d/0x30 [cfg80211] [] process_one_work+0x17f/0x420 [] worker_thread+0x11a/0x370 [] ? rescuer_thread+0x2f0/0x2f0 [] kthread+0xbb/0xc0 [] ? kthread_create_on_node+0x120/0x120 [] ret_from_fork+0x7c/0xb0 [] ? kthread_create_on_node+0x120/0x120 ---[ end trace 61f3bddc9c4981f7 ]--- The reason is that, in connect result event cfg80211 unholds the BSS to which the device is associated (and was held so far). So, for the event with status successful, when cfg80211 wants to get that BSS from the device's BSS list it gets a NULL BSS because the BSS has been expired and unheld already. Fix this by searching and saving the BSS before it gets unhold by the cfg80211. Use that saved BSS and hold it again when the assiciation is successful. Signed-off-by: Ujjal Roy --- net/wireless/sme.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 65f8008..5eeb8e0 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -589,6 +589,7 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, struct cfg80211_bss *bss) { struct wireless_dev *wdev = dev->ieee80211_ptr; + struct cfg80211_bss *save_bss = NULL; const u8 *country_ie; #ifdef CONFIG_CFG80211_WEXT union iwreq_data wrqu; @@ -632,6 +633,11 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, } #endif + if (!bss) + save_bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid, + wdev->ssid, wdev->ssid_len, + WLAN_CAPABILITY_ESS, + WLAN_CAPABILITY_ESS); if (wdev->current_bss) { cfg80211_unhold_bss(wdev->current_bss); cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); @@ -651,10 +657,7 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, if (!bss) { WARN_ON_ONCE(!wiphy_to_dev(wdev->wiphy)->ops->connect); - bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid, - wdev->ssid, wdev->ssid_len, - WLAN_CAPABILITY_ESS, - WLAN_CAPABILITY_ESS); + bss = save_bss; if (WARN_ON(!bss)) return; cfg80211_hold_bss(bss_from_pub(bss));