Skip to content

Commit 9e38bcc

Browse files
rado17henrikbrixandersen
authored andcommitted
wifi: utils: Get correct channel count
When channel range is configured in scan params, get the channel count from `chan_idx` instead of taking a difference of start and end of the channel range. The `difference` method fails in case of 5GHz band since channels may not be consecutive numbers. Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
1 parent 885d271 commit 9e38bcc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

subsys/net/l2/wifi/wifi_utils.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ static int wifi_utils_get_all_chans_in_range(uint8_t chan_start,
150150
for (i = 0; i < ARRAY_SIZE(valid_5g_chans_20mhz); i++) {
151151
if (valid_5g_chans_20mhz[i] == chan_start) {
152152
start = true;
153+
continue;
153154
}
154155

155156
if (valid_5g_chans_20mhz[i] == chan_end) {
@@ -368,10 +369,6 @@ int wifi_utils_parse_scan_chan(char *scan_chan_str,
368369
memset(chan_str, 0, sizeof(chan_str));
369370

370371
if (chan_start) {
371-
if ((chan_idx + (chan_val - chan_start)) > max_channels) {
372-
NET_ERR("Too many channels specified (%d)", max_channels);
373-
return -EINVAL;
374-
}
375372
if (wifi_utils_get_all_chans_in_range(chan_start,
376373
chan_val,
377374
band_chan,
@@ -381,6 +378,10 @@ int wifi_utils_parse_scan_chan(char *scan_chan_str,
381378
return -EINVAL;
382379
}
383380

381+
if (chan_idx > max_channels) {
382+
NET_ERR("Too many channels specified (%d)", max_channels);
383+
return -EINVAL;
384+
}
384385
chan_start = 0;
385386
} else {
386387
if (!wifi_utils_validate_chan(band,

0 commit comments

Comments
 (0)