diff mbox series

[1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel

Message ID 20230919165923.1352279-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/2] wiphy: fix wiphy_contrain_freq_set skipping last channel | expand

Commit Message

James Prestwood Sept. 19, 2023, 4:59 p.m. UTC
The loop iterating the frequency attributes list was not including
the entire channel set since it was stopping at i < band->freqs_len.
The freq_attrs array is allocated to include the last channel:

band->freq_attrs = l_new(struct band_freq_attrs, num_channels + 1);
band->freqs_len = num_channels;

So instead the for loop should use i <= band->freqs_len. (I also
changed this to start the loop at 1 since channel zero is invalid).
---
 src/wiphy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Denis Kenzior Sept. 25, 2023, 2:30 p.m. UTC | #1
Hi James,

On 9/19/23 11:59, James Prestwood wrote:
> The loop iterating the frequency attributes list was not including
> the entire channel set since it was stopping at i < band->freqs_len.
> The freq_attrs array is allocated to include the last channel:
> 
> band->freq_attrs = l_new(struct band_freq_attrs, num_channels + 1);
> band->freqs_len = num_channels;
> 
> So instead the for loop should use i <= band->freqs_len. (I also
> changed this to start the loop at 1 since channel zero is invalid).
> ---
>   src/wiphy.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Both applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/wiphy.c b/src/wiphy.c
index 77ed2acf..ccff701e 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -843,7 +843,7 @@  bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
 		if (!band)
 			continue;
 
-		for (i = 0; i < band->freqs_len; i++) {
+		for (i = 1; i <= band->freqs_len; i++) {
 			uint32_t freq;
 
 			if (!band->freq_attrs[i].supported)