diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index 41a3d801ab42..67d770d0c854 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -6089,24 +6089,28 @@ static int drv_cmd_tdls_off_channel(struct hdd_adapter *adapter, { int ret; uint8_t *value = command; - int set_value; + int channel; + enum channel_state reg_state; /* Move pointer to point the string */ value += command_len; - ret = sscanf(value, "%d", &set_value); + ret = sscanf(value, "%d", &channel); if (ret != 1) return -EINVAL; + reg_state = wlan_reg_get_channel_state(hdd_ctx->pdev, channel); - if (wlan_reg_is_dfs_ch(hdd_ctx->pdev, set_value)) { - hdd_err("DFS channel %d is passed for hdd_set_tdls_offchannel", - set_value); + if (reg_state == CHANNEL_STATE_DFS || + reg_state == CHANNEL_STATE_DISABLE || + reg_state == CHANNEL_STATE_INVALID) { + hdd_err("reg state of the channel %d is %d and not supported", + channel, reg_state); return -EINVAL; } - hdd_debug("Tdls offchannel num: %d", set_value); + hdd_debug("Tdls offchannel num: %d", channel); - ret = hdd_set_tdls_offchannel(hdd_ctx, adapter, set_value); + ret = hdd_set_tdls_offchannel(hdd_ctx, adapter, channel); return ret; }