From f4e994656f5a741f3f5a99c18053779db48ed951 Mon Sep 17 00:00:00 2001 From: Abhishek Ambure Date: Thu, 30 Jan 2020 16:16:07 +0530 Subject: [PATCH] qcacld-3.0: Handle ch cnt and number of channels for SETROAMSCANCHANNELS To set specific channels, user give SETROAMSCANCHANNELS command with channel count followed by number of channels. Ex. SETROAMSCANCHANNELS 2 1 11, here 2 is count and 1 & 11 are the channels. If channel count is more than the number of channels, driver rejects SETROAMSCANCHANNELS command and if number of channels are more than the channel count, driver ignores excess channels in the list. Change-Id: I276b84b4994bdf25abf36298dc212dcd54ce0dbb CRs-Fixed: 2609788 --- core/hdd/src/wlan_hdd_ioctl.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index 68c9af0814..ff15f28edb 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -1880,12 +1880,10 @@ hdd_parse_channellist(struct hdd_context *hdd_ctx, in_ptr = strpbrk(in_ptr, " "); /* no channel list after the number of channels argument */ if (!in_ptr) { - if (0 != j) { - *num_channels = j; + if ((j != 0) && (*num_channels == j)) return 0; - } else { - return -EINVAL; - } + else + goto cnt_mismatch; } /* remove empty space */ @@ -1897,12 +1895,10 @@ hdd_parse_channellist(struct hdd_context *hdd_ctx, * argument and spaces */ if ('\0' == *in_ptr) { - if (0 != j) { - *num_channels = j; + if ((j != 0) && (*num_channels == j)) return 0; - } else { - return -EINVAL; - } + else + goto cnt_mismatch; } v = sscanf(in_ptr, "%31s ", buf); @@ -1923,6 +1919,12 @@ hdd_parse_channellist(struct hdd_context *hdd_ctx, } return 0; + +cnt_mismatch: + hdd_debug("Mismatch in ch cnt: %d and num of ch: %d", *num_channels, j); + *num_channels = 0; + return -EINVAL; + } /**