From: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
To: Jeff Johnson <jjohnson@kernel.org>
Cc: linux-wireless@vger.kernel.org, ath12k@lists.infradead.org,
Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Subject: [PATCH ath-next 3/4] wifi: ath12k: protect new_alpha2 access with base_lock
Date: Wed, 29 Jul 2026 15:18:13 +0800 [thread overview]
Message-ID: <20260729-ath12k-regd-wait-timeout-v1-3-504aa6e7e93c@oss.qualcomm.com> (raw)
In-Reply-To: <20260729-ath12k-regd-wait-timeout-v1-0-504aa6e7e93c@oss.qualcomm.com>
ab->new_alpha2 is written under ab->base_lock by the 11d new country
code event handler ath12k_reg_11d_new_cc_event() and by the SMBIOS
BDF parser, and read under the same lock by ath12k_update_11d().
ath12k_mac_hw_register() however read ab->new_alpha2 without holding
base_lock, racing with those writers. Take base_lock and copy the
value into a local wmi_set_current_country_arg, mirroring what
ath12k_update_11d() already does, and use the local copy afterwards.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
Signed-off-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 82cbb5b9cd11..56f9c1945cf0 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -15052,11 +15052,17 @@ static int ath12k_mac_hw_register(struct ath12k_hw *ah)
goto err_unregister_hw;
}
- if (this_ab->hw_params->current_cc_support && this_ab->new_alpha2[0]) {
+ if (this_ab->hw_params->current_cc_support) {
struct wmi_set_current_country_arg current_cc = {};
+ spin_lock_bh(&this_ab->base_lock);
memcpy(¤t_cc.alpha2, this_ab->new_alpha2, 2);
- memcpy(&ar->alpha2, this_ab->new_alpha2, 2);
+ spin_unlock_bh(&this_ab->base_lock);
+
+ if (!current_cc.alpha2[0])
+ goto fw_stats_init;
+
+ memcpy(&ar->alpha2, current_cc.alpha2, 2);
reinit_completion(&ar->regd_update_completed);
@@ -15067,6 +15073,7 @@ static int ath12k_mac_hw_register(struct ath12k_hw *ah)
ret);
}
+fw_stats_init:
ath12k_fw_stats_init(ar);
ath12k_debugfs_register(ar);
}
--
2.25.1
next prev parent reply other threads:[~2026-07-29 7:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 7:18 [PATCH ath-next 0/4] wifi: ath12k: fix timeout while waiting for regulatory update on bring-up Baochen Qiang
2026-07-29 7:18 ` [PATCH ath-next 1/4] wifi: ath12k: signal regd update completion when reg event is dropped Baochen Qiang
2026-07-29 7:18 ` [PATCH ath-next 2/4] wifi: ath12k: use per-radio ab in ath12k_mac_hw_register() Baochen Qiang
2026-07-29 7:18 ` Baochen Qiang [this message]
2026-07-29 7:18 ` [PATCH ath-next 4/4] wifi: ath12k: skip setting country code during registration when unchanged Baochen Qiang
2026-08-05 17:30 ` [PATCH ath-next 0/4] wifi: ath12k: fix timeout while waiting for regulatory update on bring-up Rameshkumar Sundaram
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260729-ath12k-regd-wait-timeout-v1-3-504aa6e7e93c@oss.qualcomm.com \
--to=baochen.qiang@oss.qualcomm.com \
--cc=ath12k@lists.infradead.org \
--cc=jjohnson@kernel.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox