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 v3 2/5] wifi: ath9k: name the register multi-read limit
Date: Fri, 4 Sep 2026 21:52:50 +0300 [thread overview]
Message-ID: <20260904185253.809209-3-nerijus.bendziunas@gmail.com> (raw)
In-Reply-To: <20260904185253.809209-1-nerijus.bendziunas@gmail.com>
ath9k_multi_regread() converts the addresses and the results through
fixed 8-entry arrays and does not check the count it is given, so every
REG_READ_MULTI() caller has to stay at 8 or below, which nothing
states. Two callers ask for exactly 8: ar9271_hw_pa_cal() through
REG_READ_ARRAY() and ath9k_hw_usb_gen_fill_eeprom().
Define ATH9K_MULTI_READ_MAX next to REG_READ_MULTI() and size the
arrays with it. A larger count warns once and is reported as a failed
read, all ones, instead of writing past the arrays.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Nerijus Bendžiūnas <nerijus.bendziunas@gmail.com>
---
drivers/net/wireless/ath/ath9k/htc_drv_init.c | 9 +++++++--
drivers/net/wireless/ath/ath9k/hw.h | 7 +++++++
2 files changed, 14 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 f5844e9bdd2d..3d4c6f9f6e95 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -258,10 +258,15 @@ 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)) {
+ memset(val, 0xff, sizeof(*val) * count);
+ 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..211d42c92796 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))
+/*
+ * Maximum number of registers one REG_READ_MULTI() may ask for. The ath9k_htc
+ * implementation converts the addresses and the results through fixed arrays
+ * of this size; 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-09-04 18:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 18:52 [PATCH v3 0/5] wifi: ath9k: cut USB round trips on channel changes Nerijus Bendžiūnas
2026-09-04 18:52 ` [PATCH v3 1/5] wifi: ath9k_htc: report a failed multi-read as all ones Nerijus Bendžiūnas
2026-09-04 18:52 ` Nerijus Bendžiūnas [this message]
2026-09-04 18:52 ` [PATCH v3 3/5] wifi: ath9k: check all tx queues with one multi-read Nerijus Bendžiūnas
2026-09-04 18:52 ` [PATCH v3 4/5] wifi: ath9k: batch the read-modify-writes of a channel change Nerijus Bendžiūnas
2026-09-04 18:52 ` [PATCH v3 5/5] wifi: ath9k: skip the old 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=20260904185253.809209-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.