qcacmn: Redefine the regulatory constant INVALID_CHANNEL

Currently the INVALID_CHANNEL assumes the value 0xBAD. When a channel list
array is indexed, there is an array out of bound error when the channel
list array is indexed using INVALID_CHANNEL or when the index is greater
than equal to NUM_CHANNELS. So a check for an invalid channel enum is
likely to be, (ch_enum == INVALID_CHANNEL) && (ch_enum  >= NUM_CHANNEL).

Redefine INVALID_CHANNEL enum constant with NUM_CHANNELS constant so that,
the validity checks for channel enum is compressed as,
(ch_enum >= INVALID_CHANNEL).

Change-Id: I5be588fe6011ac85031325f56eff208f2aa7a1e5
CRs-Fixed: 3238386
This commit is contained in:
Vignesh U
2022-07-07 14:44:26 +05:30
committed by Madan Koyyalamudi
parent 3f49761156
commit 6efe5cf271
7 changed files with 54 additions and 42 deletions

View File

@@ -471,8 +471,10 @@ static uint32_t wifi_pos_get_valid_channels(qdf_freq_t *chan_freqs,
uint32_t i, num_valid_channels = 0;
for (i = 0; i < num_ch; i++) {
if (wlan_reg_get_chan_enum_for_freq(chan_freqs[i]) ==
INVALID_CHANNEL)
enum channel_enum ch_enum;
ch_enum = wlan_reg_get_chan_enum_for_freq(chan_freqs[i]);
if (reg_is_chan_enum_invalid(ch_enum))
continue;
valid_channel_list[num_valid_channels++] = chan_freqs[i];
}