Skip to content

Commit 4c4d684

Browse files
royujjaljmberg-intel
authored andcommitted
cfg80211: fix WARN_ON for re-association to the expired BSS
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: [<ffffffff81747a41>] dump_stack+0x46/0x58 [<ffffffff81045847>] warn_slowpath_common+0x87/0xb0 [<ffffffff81045885>] warn_slowpath_null+0x15/0x20 [<ffffffffa05345f6>] __cfg80211_connect_result+0x3a6/0x3e0 [cfg80211] [<ffffffff8107168b>] ? update_rq_clock+0x2b/0x50 [<ffffffff81078c01>] ? update_curr+0x1/0x160 [<ffffffffa05133d2>] cfg80211_process_wdev_events+0xb2/0x1c0 [cfg80211] [<ffffffff81079303>] ? pick_next_task_fair+0x63/0x170 [<ffffffffa0513518>] cfg80211_process_rdev_events+0x38/0x90 [cfg80211] [<ffffffffa050f03d>] cfg80211_event_work+0x1d/0x30 [cfg80211] [<ffffffff8105f21f>] process_one_work+0x17f/0x420 [<ffffffff8105f90a>] worker_thread+0x11a/0x370 [<ffffffff8105f7f0>] ? rescuer_thread+0x2f0/0x2f0 [<ffffffff8106638b>] kthread+0xbb/0xc0 [<ffffffff810662d0>] ? kthread_create_on_node+0x120/0x120 [<ffffffff817574bc>] ret_from_fork+0x7c/0xb0 [<ffffffff810662d0>] ? 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 <royujjal@gmail.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 0834ae3 commit 4c4d684

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

‎net/wireless/sme.c‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,16 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
632632
}
633633
#endif
634634

635+
if (!bss && (status == WLAN_STATUS_SUCCESS)) {
636+
WARN_ON_ONCE(!wiphy_to_dev(wdev->wiphy)->ops->connect);
637+
bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
638+
wdev->ssid, wdev->ssid_len,
639+
WLAN_CAPABILITY_ESS,
640+
WLAN_CAPABILITY_ESS);
641+
if (bss)
642+
cfg80211_hold_bss(bss_from_pub(bss));
643+
}
644+
635645
if (wdev->current_bss) {
636646
cfg80211_unhold_bss(wdev->current_bss);
637647
cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
@@ -649,16 +659,8 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
649659
return;
650660
}
651661

652-
if (!bss) {
653-
WARN_ON_ONCE(!wiphy_to_dev(wdev->wiphy)->ops->connect);
654-
bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
655-
wdev->ssid, wdev->ssid_len,
656-
WLAN_CAPABILITY_ESS,
657-
WLAN_CAPABILITY_ESS);
658-
if (WARN_ON(!bss))
659-
return;
660-
cfg80211_hold_bss(bss_from_pub(bss));
661-
}
662+
if (WARN_ON(!bss))
663+
return;
662664

663665
wdev->current_bss = bss_from_pub(bss);
664666

0 commit comments

Comments
 (0)