From: "Nerijus Bendžiūnas" <nerijus.bendziunas@gmail.com>
To: "Toke Høiland-Jørgensen" <toke@toke.dk>, linux-wireless@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 1/4] wifi: ath9k: name the register multi-read limit
Date: Sat, 29 Aug 2026 08:43:58 +0300 [thread overview]
Message-ID: <20260829054401.1198574-2-nerijus.bendziunas@gmail.com> (raw)
In-Reply-To: <20260829054401.1198574-1-nerijus.bendziunas@gmail.com>
ath9k_multi_regread() converts the addresses and the results through
fixed eight-entry arrays without checking the count it was given, so
every REG_READ_MULTI() caller has to stay at or below eight to be safe
over USB. Nothing says so. The only caller that exists today,
ar9271_hw_pa_cal(), happens to ask for exactly eight.
Give the limit a name next to REG_READ_MULTI(), size the arrays with it,
and warn rather than write past them.
Signed-off-by: Nerijus Bendžiūnas <nerijus.bendziunas@gmail.com>
---
drivers/net/wireless/ath/ath9k/htc_drv_init.c | 7 +++++--
drivers/net/wireless/ath/ath9k/hw.h | 7 +++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 6de78ae85726..7fdec25c76ef 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -258,10 +258,13 @@ static void ath9k_multi_regread(void *hw_priv, u32 *addr,
struct ath_hw *ah = hw_priv;
struct ath_common *common = ath9k_hw_common(ah);
struct ath9k_htc_priv *priv = common->priv;
- __be32 tmpaddr[8];
- __be32 tmpval[8];
+ __be32 tmpaddr[ATH9K_MULTI_READ_MAX];
+ __be32 tmpval[ATH9K_MULTI_READ_MAX];
int i, ret;
+ if (WARN_ON_ONCE(count > ATH9K_MULTI_READ_MAX))
+ return;
+
for (i = 0; i < count; i++) {
tmpaddr[i] = cpu_to_be32(addr[i]);
}
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index b942b8303d8f..946c4d307b91 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -83,6 +83,13 @@
#define REG_READ(_ah, _reg) \
(_ah)->reg_ops.read((_ah), (_reg))
+/*
+ * Registers a single REG_READ_MULTI() may ask for. The USB transport carries
+ * the addresses and the results in one WMI command each, so its buffers put a
+ * hard cap on the count; callers must split larger reads themselves.
+ */
+#define ATH9K_MULTI_READ_MAX 8
+
#define REG_READ_MULTI(_ah, _addr, _val, _cnt) \
(_ah)->reg_ops.multi_read((_ah), (_addr), (_val), (_cnt))
--
2.55.0
next prev parent reply other threads:[~2026-08-29 5:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 5:43 [PATCH 0/4] wifi: ath9k: cut USB round trips on channel changes Nerijus Bendžiūnas
2026-08-29 5:43 ` Nerijus Bendžiūnas [this message]
2026-08-29 5:43 ` [PATCH 2/4] wifi: ath9k: check all tx queues with one multi-read Nerijus Bendžiūnas
2026-08-29 5:44 ` [PATCH 3/4] wifi: ath9k: batch the read-modify-writes of a channel change Nerijus Bendžiūnas
2026-08-29 5:44 ` [PATCH 4/4] wifi: ath9k: skip the departing channel's noise floor on USB fast changes Nerijus Bendžiūnas
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=20260829054401.1198574-2-nerijus.bendziunas@gmail.com \
--to=nerijus.bendziunas@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=toke@toke.dk \
/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