diff --git a/wifimngr.c b/wifimngr.c index dbc01f018f107f62858f5809417906511912ae58..f2af462caeccb705bb36e4d0c849d82d8032409b 100644 --- a/wifimngr.c +++ b/wifimngr.c @@ -1894,18 +1894,31 @@ int wl_scan_ex(struct ubus_context *ctx, struct ubus_object *obj, p = &supp_chan[sum]; } + for (i = 0; i < sum; i++) { + sp.freq[idx] = wifi_channel_to_freq_ex(supp_chan[i], oper_band); + if (sp.freq[idx] < 0) { + wifimngr_err("No freq for channel %d\n", supp_chan[i]); + continue; + } + idx++; + } + for (i = 0; i < ch_idx; i++) { /* check each channel */ for (j = 0; j < sum; j++) { - if (channels[i] == supp_chan[j]) { - sp.freq[idx] = wifi_channel_to_freq_ex(channels[i], oper_band); - if (sp.freq[idx] < 0) { - wifimngr_err("No freq for channel %d\n", channels[i]); - continue; - } - idx++; + if (channels[i] == supp_chan[j]) break; - } } + + /* We already add this channel */ + if (j != sum) + continue; + + sp.freq[idx] = wifi_channel_to_freq_ex(channels[i], oper_band); + if (sp.freq[idx] < 0) { + wifimngr_err("No freq for channel %d\n", channels[i]); + continue; + } + idx++; } sp.num_freq = idx; }