From: m.limarencko@yandex.ru
To: jjohnson@kernel.org
Cc: linux-wireless@vger.kernel.org, ath12k@lists.infradead.org,
linux-kernel@vger.kernel.org,
Mikhail Limarenko <m.limarencko@yandex.ru>
Subject: [PATCH ath-next v2 1/4] wifi: ath12k: return error when survey frequency is not found
Date: Thu, 12 Feb 2026 15:17:43 +0300 [thread overview]
Message-ID: <20260212121746.329619-2-m.limarencko@yandex.ru> (raw)
In-Reply-To: <20260212121746.329619-1-m.limarencko@yandex.ru>
From: Mikhail Limarenko <m.limarencko@yandex.ru>
freq_to_idx() currently returns a trailing synthetic index when the
requested channel frequency is not found.
chan-info handlers already bound-check survey index, but an explicit
error on no-match keeps semantics clear and avoids propagating a fake
index value.
Keep matched-frequency index progression unchanged, return -ENOENT on
no match, and make callers reject negative indexes.
Tested-on: QCNFA765 (WCN785x), kernel 6.18.5+deb13-amd64
Signed-off-by: Mikhail Limarenko <m.limarencko@yandex.ru>
---
v2:
- drop out-of-bounds claim from commit message
- keep original index progression for matched frequencies
- return explicit -ENOENT on no-match and reject negative idx in callers
drivers/net/wireless/ath/ath12k/wmi.c | 9 +++------
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index e647b84..a2f8a7c 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -6528,12 +6528,11 @@ static int freq_to_idx(struct ath12k *ar, int freq)
continue;
if (sband->channels[ch].center_freq == freq)
- goto exit;
+ return idx;
}
}
-exit:
- return idx;
+ return -ENOENT;
}
static int ath12k_pull_chan_info_ev(struct ath12k_base *ab, struct sk_buff *skb,
@@ -7475,7 +7474,7 @@ static void ath12k_chan_info_event(struct ath12k_base *ab, struct sk_buff *skb)
}
idx = freq_to_idx(ar, le32_to_cpu(ch_info_ev.freq));
- if (idx >= ARRAY_SIZE(ar->survey)) {
+ if (idx < 0 || idx >= ARRAY_SIZE(ar->survey)) {
ath12k_warn(ab, "chan info: invalid frequency %d (idx %d out of bounds)\n",
ch_info_ev.freq, idx);
goto exit;
@@ -7550,7 +7549,7 @@ ath12k_pdev_bss_chan_info_event(struct ath12k_base *ab, struct sk_buff *skb)
spin_lock_bh(&ar->data_lock);
idx = freq_to_idx(ar, le32_to_cpu(bss_ch_info_ev.freq));
- if (idx >= ARRAY_SIZE(ar->survey)) {
+ if (idx < 0 || idx >= ARRAY_SIZE(ar->survey)) {
ath12k_warn(ab, "bss chan info: invalid frequency %d (idx %d out of bounds)\n",
bss_ch_info_ev.freq, idx);
goto exit;
--
2.47.3
next prev parent reply other threads:[~2026-02-12 12:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 12:17 [PATCH ath-next v2 0/4] wifi: ath12k: harden stats/rate handling for WCN785x stability m.limarencko
2026-02-12 12:17 ` m.limarencko [this message]
2026-02-12 12:17 ` [PATCH ath-next v2 2/4] wifi: ath12k: avoid long fw_stats waits on vdev stats hot path m.limarencko
2026-02-26 1:50 ` Baochen Qiang
2026-02-12 12:17 ` [PATCH ath-next v2 3/4] wifi: ath12k: sanitize invalid MCS metadata in rx path m.limarencko
2026-02-12 12:17 ` [PATCH ath-next v2 4/4] wifi: ath12k: sanitize invalid MCS metadata in monitor " m.limarencko
2026-02-25 22:24 ` [PATCH ath-next v2 0/4] wifi: ath12k: harden stats/rate handling for WCN785x stability Jeff Johnson
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=20260212121746.329619-2-m.limarencko@yandex.ru \
--to=m.limarencko@yandex.ru \
--cc=ath12k@lists.infradead.org \
--cc=jjohnson@kernel.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®