Browse Source

qcacmn: Update array boundary checks for regulatory API

The regulatory API reg_freq_to_chan_for_chlist()  uses num_chans as the
bound to access the array chan_list. While an invalid index INVALID_CHANNEL
is prevented from accessing chan_list, values that are greater than
NUM_CHANNELS are not prevented from accessing the array.

Prevent access to the array when the index is greater than NUM_CHANNELS.
Since INVALID_CHANNEL is also greater than NUM_CHANNELS, the existing
condition that prevents access to the array when num_chans is
INVALID_CHANNEL can be removed.

Change-Id: I8b9793b84fc5b3a9406389fd3482673dd4667cfc
CRs-Fixed: 3196165
Vignesh U 3 years ago
parent
commit
e22d6a62b8
1 changed files with 1 additions and 1 deletions
  1. 1 1
      umac/regulatory/core/src/reg_services_common.c

+ 1 - 1
umac/regulatory/core/src/reg_services_common.c

@@ -1488,7 +1488,7 @@ reg_freq_to_chan_for_chlist(struct regulatory_channel *chan_list,
 {
 	uint32_t count;
 
-	if (num_chans == INVALID_CHANNEL) {
+	if (num_chans > NUM_CHANNELS) {
 		reg_err_rl("invalid num_chans");
 		return 0;
 	}