Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp509510imw; Wed, 13 Jul 2022 02:49:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s2hr85upHvRjnP/DNahpaxBO9jFp1RqKeJCDEoeFtEvQfhfl7ClLhhhhz4cY5VEcQn53ex X-Received: by 2002:aa7:8895:0:b0:528:c6c7:c603 with SMTP id z21-20020aa78895000000b00528c6c7c603mr2488219pfe.46.1657705709728; Wed, 13 Jul 2022 02:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657705709; cv=none; d=google.com; s=arc-20160816; b=Bf0aublDL+rFe5J/FTCsTp6ph/bjZ3jnGrjXktZzadmEA/21AaH1aooPBiGzcbMPcg YJdD9LRNHQITe+hKRiwqObOvUy34W4C+9kjKX2LNsnY7i5/vY5InlPBNVpBMgdQXMtOo nkvme8vWh88usnDscaZNWsZXIkSzoLZBLBI3xSDTJabgJrRmXVY9RrOfFfpKeqi1LsLd RuVJFsfSB9MW7BIQrfwA88qTzCq/Vsi5kDJoUEDYGfjIbaMgdahxSC3F9VPOHdlfor2a 0dlT0BexWP2aJNOnC6Xu9jfb8lfaU2P4cHLpyz5SXkE2l8fi9GIOxi8E9lagar7oRZQ6 Vlow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DG76LziSNeDUfVmn9tJn46vQ4awamEJ6AFjSoI70F0c=; b=S/kBTv48AbSRD3VphK+HAPHIU7Qd57SeX9mPROAdrKG7WJlrwDxE0iajt2htAT1p8J NFCimO1HyQUUcJ1JNjagqB79nvN9NWr6S91p+OfUHT1omXibLanrFHDNQyzMw62caDS/ GdhfruTEWEY8UqAXWifKVPxu/mVsUKruyRGQCZqK0AUrxqFMePO1obhCYFlGGDHkwLsi SVyb2YVy21PZT+ZBS91Cn6JLoJHGIcOJwFaNjFXQ/igu+iu9JJxLZv9QXAYqiY7tZpRD oVceSibG7qn1PdX3VB4drKraqo5GgZS+QXetDE6GLRRw0RWN4V/eViEQU3vdeyytn/O9 97NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=TOmrosvy; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a184-20020a6390c1000000b0041183dcd4bfsi16687763pge.147.2022.07.13.02.48.21; Wed, 13 Jul 2022 02:48:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=TOmrosvy; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231550AbiGMJpU (ORCPT + 65 others); Wed, 13 Jul 2022 05:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235488AbiGMJpL (ORCPT ); Wed, 13 Jul 2022 05:45:11 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05A45EF9C9 for ; Wed, 13 Jul 2022 02:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=DG76LziSNeDUfVmn9tJn46vQ4awamEJ6AFjSoI70F0c=; t=1657705510; x=1658915110; b=TOmrosvyTLP4o5vaDN1BAX3kTbOAI8tLTXLZWF/RPBoflKG NMxnU5NN0fekhBifCqn9ulFurY/upBujNAA90fJCYPeUCXqHY7zjNBFRKjTT/4BF2aWudztTWS7Ey OZgJ5d/sUSd2jNXhrhtJt4BLQSgz4bSISiCx7HUB7wOxuc/JccXUnyP3yf19ukwSC6VoBbpsWA5++ 81DOrmTSt44ZBkgMUzBJuN5+fQIdK3FyHFnzRAWTSc7Vd+5DgFhBpoGfeUyvou495EoDVbxovSURt w8CM1QvaB97TwhII+yvB54JISiErLMBgu0RwWC/Ab604rMnVK9oZuAn4nqSJnDVg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1oBYvb-00EgvB-T2; Wed, 13 Jul 2022 11:45:07 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH 12/76] wifi: nl80211: hold wdev mutex for channel switch APIs Date: Wed, 13 Jul 2022 11:43:58 +0200 Message-Id: <20220713114425.6f718736f921.Ie0fba6025a9fe4bd0ec64fb5fff2d8765a5837fd@changeid> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220713094502.163926-1-johannes@sipsolutions.net> References: <20220713094502.163926-1-johannes@sipsolutions.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Since we deal with links in an MLD here, hold the wdev mutex now. Signed-off-by: Johannes Berg --- net/wireless/nl80211.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 26d277c14fd4..59ea1157969e 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -3348,8 +3348,13 @@ static int nl80211_set_channel(struct sk_buff *skb, struct genl_info *info) struct cfg80211_registered_device *rdev = info->user_ptr[0]; int link_id = nl80211_link_id_or_invalid(info->attrs); struct net_device *netdev = info->user_ptr[1]; + int ret; + + wdev_lock(netdev->ieee80211_ptr); + ret = __nl80211_set_channel(rdev, netdev, info, link_id); + wdev_unlock(netdev->ieee80211_ptr); - return __nl80211_set_channel(rdev, netdev, info, link_id); + return ret; } static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) @@ -3461,10 +3466,16 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) } if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { - result = __nl80211_set_channel( - rdev, - nl80211_can_set_dev_channel(wdev) ? netdev : NULL, - info, -1); + if (wdev) { + wdev_lock(wdev); + result = __nl80211_set_channel( + rdev, + nl80211_can_set_dev_channel(wdev) ? netdev : NULL, + info, -1); + wdev_unlock(wdev); + } else { + result = __nl80211_set_channel(rdev, netdev, info, -1); + } if (result) goto out; } -- 2.36.1