summaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorKarthikeyan Kathirvel <kathirve@codeaurora.org>2021-03-11 10:59:07 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-10 13:36:08 +0200
commit0a66bd60b1ce67940447c24e673fac11296bcd9d (patch)
treec840d66225fb08d24b9b99a5d420df516a57d73b /net/mac80211
parent7705c48b8695c8a05fe0c23443c5da7e84a9eb76 (diff)
downloadlinux-stable-0a66bd60b1ce67940447c24e673fac11296bcd9d.tar.gz
linux-stable-0a66bd60b1ce67940447c24e673fac11296bcd9d.tar.bz2
linux-stable-0a66bd60b1ce67940447c24e673fac11296bcd9d.zip
mac80211: choose first enabled channel for monitor
[ Upstream commit 041c881a0ba8a75f71118bd9766b78f04beed469 ] Even if the first channel from sband channel list is invalid or disabled mac80211 ends up choosing it as the default channel for monitor interfaces, making them not usable. Fix this by assigning the first available valid or enabled channel instead. Signed-off-by: Karthikeyan Kathirvel <kathirve@codeaurora.org> Link: https://lore.kernel.org/r/1615440547-7661-1-git-send-email-kathirve@codeaurora.org [reword commit message, comment, code cleanups] Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 523380aed92e..19c093bb3876 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -982,8 +982,19 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
continue;
if (!dflt_chandef.chan) {
+ /*
+ * Assign the first enabled channel to dflt_chandef
+ * from the list of channels
+ */
+ for (i = 0; i < sband->n_channels; i++)
+ if (!(sband->channels[i].flags &
+ IEEE80211_CHAN_DISABLED))
+ break;
+ /* if none found then use the first anyway */
+ if (i == sband->n_channels)
+ i = 0;
cfg80211_chandef_create(&dflt_chandef,
- &sband->channels[0],
+ &sband->channels[i],
NL80211_CHAN_NO_HT);
/* init channel we're on */
if (!local->use_chanctx && !local->_oper_chandef.chan) {