From: Johannes Berg 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. 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 1a67d146bf2b..ed4d43a8cb78 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -2859,12 +2859,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); } @@ -3946,9 +3946,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; -- 2.55.0