diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 706d8396cdbb..3dcce54da58d 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -7977,10 +7977,12 @@ __wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, int ret; qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); uint16_t *local_unsafe_list; + uint16_t unsafe_channel_count; uint16_t unsafe_channel_index, local_unsafe_list_count; struct ch_avoid_ind_type *channel_list; enum QDF_GLOBAL_MODE curr_mode; uint8_t num_args = 0; + bool user_set_avoid_channel = true; hdd_enter_dev(wdev->netdev); @@ -7998,6 +8000,11 @@ __wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, ret = wlan_hdd_validate_context(hdd_ctx); if (0 != ret) return ret; + if (!data && data_len == 0) { + hdd_debug("Userspace doesn't set avoid frequency channel list"); + user_set_avoid_channel = false; + goto process_unsafe_channel; + } if (!data || data_len < (sizeof(channel_list->ch_avoid_range_cnt) + sizeof(struct ch_avoid_freq_type))) { hdd_err("Avoid frequency channel list empty"); @@ -8021,6 +8028,7 @@ __wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, return -EINVAL; } +process_unsafe_channel: ret = hdd_clone_local_unsafe_chan(hdd_ctx, &local_unsafe_list, &local_unsafe_list_count); @@ -8032,16 +8040,24 @@ __wlan_hdd_cfg80211_avoid_freq(struct wiphy *wiphy, pld_get_wlan_unsafe_channel(qdf_ctx->dev, hdd_ctx->unsafe_channel_list, &(hdd_ctx->unsafe_channel_count), sizeof(hdd_ctx->unsafe_channel_list)); - - hdd_ctx->unsafe_channel_count = hdd_validate_avoid_freq_chanlist( + if (user_set_avoid_channel) { + hdd_ctx->unsafe_channel_count = + hdd_validate_avoid_freq_chanlist( hdd_ctx, channel_list); + unsafe_channel_count = hdd_ctx->unsafe_channel_count; - pld_set_wlan_unsafe_channel(qdf_ctx->dev, hdd_ctx->unsafe_channel_list, - hdd_ctx->unsafe_channel_count); + pld_set_wlan_unsafe_channel(qdf_ctx->dev, + hdd_ctx->unsafe_channel_list, + hdd_ctx->unsafe_channel_count); + } else { + unsafe_channel_count = QDF_MIN( + (uint16_t)hdd_ctx->unsafe_channel_count, + (uint16_t)NUM_CHANNELS); + } for (unsafe_channel_index = 0; - unsafe_channel_index < hdd_ctx->unsafe_channel_count; + unsafe_channel_index < unsafe_channel_count; unsafe_channel_index++) { hdd_debug("Channel %d is not safe", hdd_ctx->unsafe_channel_list[unsafe_channel_index]);