[PATCH] wifi: ath12k: Fix invalid frequency error in freq_to_idx

Baochen Qiang baochen.qiang at oss.qualcomm.com
Sun Jan 25 19:38:49 PST 2026



On 1/23/2026 11:57 PM, Saikiran wrote:
> During suspend/resume, the following error is observed in dmesg:
>   ath12k_pci 0004:01:00.0: chan info: invalid frequency <freq> (idx 101 out of bounds)
> 
> This occurs because freq_to_idx() incorrectly filters channels based on
> ar->freq_range.start_freq and ar->freq_range.end_freq. These values can be
> temporarily zeroed out (e.g., during regulatory updates or suspend/resume
> sequences) while the hardware is still operational or reporting status.
> 
> When these values are zero, the filter skips all valid channels, causing
> the function to return the total channel count (e.g. 101) instead of the
> actual index, triggering the out-of-bounds warning.
> 
> Remove the broken frequency range filtering from freq_to_idx(). Channel
> mapping should depend only on the hardware band definition, not on the
> transient regulatory frequency range. This mirrors the fix recently applied
> to ath12k_reg_update_chan_list().
> 
> Tested-on: Lenovo Yoga Slim 7x
> 
> Signed-off-by: Saikiran <bjsaikiran at gmail.com>
> ---
>  drivers/net/wireless/ath/ath12k/wmi.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
> index be8b2943094f..bef1b324b62c 100644
> --- a/drivers/net/wireless/ath/ath12k/wmi.c
> +++ b/drivers/net/wireless/ath/ath12k/wmi.c
> @@ -6576,11 +6576,7 @@ static int freq_to_idx(struct ath12k *ar, int freq)
>  			continue;
>  
>  		for (ch = 0; ch < sband->n_channels; ch++, idx++) {
> -			if (sband->channels[ch].center_freq <
> -			    KHZ_TO_MHZ(ar->freq_range.start_freq) ||
> -			    sband->channels[ch].center_freq >
> -			    KHZ_TO_MHZ(ar->freq_range.end_freq))
> -				continue;
> +
>  
>  			if (sband->channels[ch].center_freq == freq)
>  				goto exit;


this has been fixed upstream, though for a different issue.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1fed08c5519d2f929457f354d3c06c6a8c33829c



More information about the ath12k mailing list