From 379d1a3471075321c246944d97cdf41109186c1b Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Oct 2026 12:04:05 +0200 Subject: [PATCH] wifi: cfg80211: reg: set intersected regd under wiphy mutex When regulatory request is intersected, the wiphy's regd is replaced holding only the RTNL, while the non-intersected case holds the wiphy mutex - we document access to need it. Current readers that don't hold RTNL also don't get into it, but it's more consistent and I want to remove the RTNL later. Also move the similar code in reg_process_hint_driver() to the same pattern as preparation. Link: https://patch.msgid.link/20261006120655.a60980246fcb.Id7ac6e91aecb976f1897aa3a211a3eb7c871831e@changeid Signed-off-by: Johannes Berg --- net/wireless/reg.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 1626a9b7c7c9..13d6fc5a56aa 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -2865,12 +2865,12 @@ reg_process_hint_driver(struct wiphy *wiphy, if (IS_ERR(regd)) return REG_REQ_IGNORE; - tmp = get_wiphy_regdom(wiphy); ASSERT_RTNL(); scoped_guard(wiphy, wiphy) { + tmp = get_wiphy_regdom(wiphy); rcu_assign_pointer(wiphy->regd, regd); + rcu_free_regdom(tmp); } - rcu_free_regdom(tmp); } @@ -3952,9 +3952,11 @@ static int reg_set_rd_driver(const struct ieee80211_regdomain *rd, * However if a driver requested this specific regulatory * domain we keep it for its private use */ - tmp = get_wiphy_regdom(request_wiphy); - rcu_assign_pointer(request_wiphy->regd, rd); - rcu_free_regdom(tmp); + scoped_guard(wiphy, request_wiphy) { + tmp = get_wiphy_regdom(request_wiphy); + rcu_assign_pointer(request_wiphy->regd, rd); + rcu_free_regdom(tmp); + } rd = NULL;