From patchwork Wed Jul 13 09:43:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 590356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46E4EC43334 for ; Wed, 13 Jul 2022 09:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235260AbiGMJpV (ORCPT ); Wed, 13 Jul 2022 05:45:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235411AbiGMJpL (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 BA82EEEAB6 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=0Hnlfk7h3sjjJxbe/5bc5EHK9aI6rOQ2u8skrMeKwsM=; t=1657705509; x=1658915109; b=NU0duGtKUEbjO3yORuZ6APrYLbDQUhUnoF8xVgBUOawh+0P 3LBzPvSCRad+62mRDAl2mlHNB0TCMKXIUDJj+VUJkpBbu/DBCbF/0QLAh0v14Sw6b3KwqK8sx6iSF aq0vHdKJyKhfjmpzyjxmV9l3thrWdkLLp8srU9oP+JpiWWAFSq/txeIpTqQhoFXCcpPLx7lvS4KQ2 utyGpSIwH94vO/iQQavIWz7I3v1N3jqinp5z7w05S6KVth4hf5bJxRXIDLeXGsMXNoANpJbEtyavt AeocIWz+qWx7enVXZcZ8rWq79zY8oBP1GF1XYQRSOfYwap1/MnJmnSd7E8DzAqGg==; 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-Kv; Wed, 13 Jul 2022 11:45:07 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH 11/76] wifi: nl80211: hold wdev mutex in add/mod/del link station Date: Wed, 13 Jul 2022 11:43:57 +0200 Message-Id: <20220713114425.6ae3d87939e9.I5ae7161064d870033ef792be09efaca652af31ca@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 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Since we deal with links, and that requires looking at wdev links, we should hold the wdev mutex for driver convenience. Signed-off-by: Johannes Berg --- net/wireless/nl80211.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 5f6cbc2d73b4..26d277c14fd4 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -15781,9 +15781,14 @@ nl80211_add_mod_link_station(struct sk_buff *skb, struct genl_info *info, if (err) return err; + wdev_lock(dev->ieee80211_ptr); if (add) - return rdev_add_link_station(rdev, dev, ¶ms); - return rdev_mod_link_station(rdev, dev, ¶ms); + err = rdev_add_link_station(rdev, dev, ¶ms); + else + err = rdev_mod_link_station(rdev, dev, ¶ms); + wdev_unlock(dev->ieee80211_ptr); + + return err; } static int @@ -15804,6 +15809,7 @@ nl80211_remove_link_station(struct sk_buff *skb, struct genl_info *info) struct link_station_del_parameters params = {}; struct cfg80211_registered_device *rdev = info->user_ptr[0]; struct net_device *dev = info->user_ptr[1]; + int ret; if (!rdev->ops->del_link_station) return -EOPNOTSUPP; @@ -15815,7 +15821,11 @@ nl80211_remove_link_station(struct sk_buff *skb, struct genl_info *info) params.mld_mac = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); params.link_id = nla_get_u8(info->attrs[NL80211_ATTR_MLO_LINK_ID]); - return rdev_del_link_station(rdev, dev, ¶ms); + wdev_lock(dev->ieee80211_ptr); + ret = rdev_del_link_station(rdev, dev, ¶ms); + wdev_unlock(dev->ieee80211_ptr); + + return ret; } #define NL80211_FLAG_NEED_WIPHY 0x01