From patchwork Wed Dec 4 11:57:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Roy, UjjaL" X-Patchwork-Id: 3281871 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D211C9F37C for ; Wed, 4 Dec 2013 11:58:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 890F020462 for ; Wed, 4 Dec 2013 11:58:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9FC5B203B4 for ; Wed, 4 Dec 2013 11:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932305Ab3LDL6A (ORCPT ); Wed, 4 Dec 2013 06:58:00 -0500 Received: from mail-pb0-f54.google.com ([209.85.160.54]:54363 "EHLO mail-pb0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932180Ab3LDL57 (ORCPT ); Wed, 4 Dec 2013 06:57:59 -0500 Received: by mail-pb0-f54.google.com with SMTP id un15so23362986pbc.13 for ; Wed, 04 Dec 2013 03:57:58 -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=n7hXVD9xw22RiBuPN7nqp2/FdJCiMT/DW/jX9/1KDAQ=; b=bUKcoqYKWz1mErnxqEr3x0Ml6XGL+6J/8Bogu6tMUkH5xXafTs36qxJnRUMsY2pkQs acYlf3zcnTgAlsJR88y+eyxEeBIWpy+1jTUxtnl7ASrNYew8Vk20lGOYAmxfBjVC+hVR M7OFO11KL2D2YxeSdA+M7Jy2EtUbqC4hcrUxobVa/oDKi99DL26a8wtm1MXl4+td4Ks5 d38N+8LT12AYgJh/5DWQD6juPWCR66V+IrfFb2dZvJJUrlPoXSCoLy2Y3Rh7zxiJ7jpi a+m0VOdTFQzOn7Pl0lJhbH0vvHg+75ggcxJCgk9w95anI6S5cMJes7peAklphzQ0aa2H tp8g== X-Received: by 10.68.160.69 with SMTP id xi5mr1058823pbb.168.1386158278836; Wed, 04 Dec 2013 03:57:58 -0800 (PST) Received: from localhost.localdomain (gw.alumnux.com. [121.243.14.254]) by mx.google.com with ESMTPSA id vk17sm1862327pab.5.2013.12.04.03.57.56 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2013 03:57:57 -0800 (PST) From: Ujjal Roy To: Johannes Berg Cc: "John W. Linville" , Subject: [PATCH] cfg80211: fix WARN_ON for re-association to the expired BSS Date: Wed, 4 Dec 2013 17:27:34 +0530 Message-Id: <1386158254-10647-1-git-send-email-royujjal@gmail.com> X-Mailer: git-send-email 1.8.1.4 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 it by reshuffling the code. Signed-off-by: Ujjal Roy --- net/wireless/sme.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 65f8008..d3c5bd7 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -632,6 +632,16 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, } #endif + if (!bss && (status == WLAN_STATUS_SUCCESS)) { + 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); + if (bss) + cfg80211_hold_bss(bss_from_pub(bss)); + } + if (wdev->current_bss) { cfg80211_unhold_bss(wdev->current_bss); cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); @@ -649,16 +659,8 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, return; } - 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); - if (WARN_ON(!bss)) - return; - cfg80211_hold_bss(bss_from_pub(bss)); - } + if (WARN_ON(!bss)) + return; wdev->current_bss = bss_from_pub(bss);