From patchwork Fri Apr 9 09:53:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 418770 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81BEAC433B4 for ; Fri, 9 Apr 2021 10:00:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5AE07611BE for ; Fri, 9 Apr 2021 10:00:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233857AbhDIKAR (ORCPT ); Fri, 9 Apr 2021 06:00:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:45122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233511AbhDIJ6q (ORCPT ); Fri, 9 Apr 2021 05:58:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D33F3611BE; Fri, 9 Apr 2021 09:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617962299; bh=PEsWAovB893nxOhB0lObleZhDaezFPfqrvJWImgeMPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JtzefQIofkDJSeyJodM7WDViCBYafTEXxnaepTyhHwO9LusSLTsuPkDsFSVhyYVQ5 1vX4nRtV0z1VneQoszIfyRkoaFbIWs+58aKr9Kgw45NoeEoiehN/ll4qF8uGx4rMNc CHiqPjdfFvRzWQlOmOmywGyH33rJfskNAYrFokK4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Karthikeyan Kathirvel , Johannes Berg , Sasha Levin Subject: [PATCH 5.4 08/23] mac80211: choose first enabled channel for monitor Date: Fri, 9 Apr 2021 11:53:38 +0200 Message-Id: <20210409095303.168335295@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210409095302.894568462@linuxfoundation.org> References: <20210409095302.894568462@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Karthikeyan Kathirvel [ 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 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 Signed-off-by: Sasha Levin --- net/mac80211/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 3e8561c3b0e7..5b3189a37680 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -954,8 +954,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) {