diff --git a/src/cntlr.h b/src/cntlr.h index 503e1e09e9823d35d669ad7b2e08328bb421d83f..da80e94bf2de1b31a619e418dfa1a358a4544269 100644 --- a/src/cntlr.h +++ b/src/cntlr.h @@ -333,6 +333,7 @@ struct controller { struct wifi_data_element dlem; /* wifi data elements */ }; +#define STA_CHANNEL_REPORT_MAX_NUM 32 struct sta_channel_report { uint8_t opclass; #define STA_CHANNEL_REPORT_MAX_CHAN 64 diff --git a/src/cntlr_map.c b/src/cntlr_map.c index fd8d492ccd20da3551f2ade3c1b519cfc6a1a809..040c57450d45de57e55e2a9abaf917abd1c5315f 100644 --- a/src/cntlr_map.c +++ b/src/cntlr_map.c @@ -1891,6 +1891,9 @@ static void _cntlr_create_sta_channel_reports(struct wifi_radio_element *radio, /* Always use /20 classid for beacon metrics */ cl_id = wifi_opclass_get_id(pref_opclass, oe->channel[0].channel, 20); + if (WARN_ON(!cl_id)) + return; + for (j = 0; j < *num_report; j++) { if (reports[j].opclass == cl_id) /* opclass already present in report */ @@ -1898,6 +1901,13 @@ static void _cntlr_create_sta_channel_reports(struct wifi_radio_element *radio, } if (j == *num_report) { + + if (*num_report >= STA_CHANNEL_REPORT_MAX_NUM) { + warn("|%s:%d| maximum number of channel reports reached\n", + __func__, __LINE__); + return; + } + /* add this opclass to the report */ reports[(*num_report)++].opclass = cl_id; } @@ -1951,7 +1961,7 @@ static int cntlr_request_bcn_metrics_sta(struct controller *c, struct sta *s) uint8_t wildcard[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; uint8_t opclass = 0; uint8_t channel = 255; /* use channel report by default */ - struct sta_channel_report reports[16]; + struct sta_channel_report reports[STA_CHANNEL_REPORT_MAX_NUM]; uint8_t num_report = 0; trace("%s: --->\n", __func__);