diff options
| author | Pragaspathi Thilagaraj <tpragasp@codeaurora.org> | 2018-10-04 12:58:53 +0530 |
|---|---|---|
| committer | Pragaspathi Thilagaraj <tpragasp@codeaurora.org> | 2018-10-29 12:20:56 +0530 |
| commit | b6424aa76296df01ec04dc2c1d4d6abaf0e02aad (patch) | |
| tree | e16355ae9950bef3d5add7473b6f9b87f6c1c930 | |
| parent | c1c92e6aab3a998b0a6f4aea8b66029073a62be8 (diff) | |
qcacld-2.0: Check for following radio link stats events
When first WMI_RADIO_LINK_STATS_EVENTID is received radio stats buffer
is allocated based on num_radio param. There is an option for pending
following events. So update wma_unified_link_radio_stats_event_handler
to check if following events are valid wrt num_radio values to avoid
buffer overwrites.
Change-Id: Ibd6550d2ff71d04a15f4f6cda1eb9c213bc1d3e1
CRs-fixed: 2340581
| -rw-r--r-- | CORE/SERVICES/WMA/wma.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/CORE/SERVICES/WMA/wma.c b/CORE/SERVICES/WMA/wma.c index 211dd79391ef..4468b4755d25 100644 --- a/CORE/SERVICES/WMA/wma.c +++ b/CORE/SERVICES/WMA/wma.c @@ -5433,18 +5433,26 @@ static int wma_unified_link_radio_stats_event_handler(void *handle, return -EINVAL; } - link_stats_results_size = sizeof(*link_stats_results) + + if (NULL == wma_handle->link_stats_results) { + link_stats_results_size = sizeof(*link_stats_results) + radio_stats_size + (radio_stats->num_channels * chan_stats_size); - wma_handle->link_stats_results = vos_mem_malloc(link_stats_results_size); - if (NULL == wma_handle->link_stats_results) { - WMA_LOGD("%s: could not allocate mem for stats results-len %zu", - __func__, link_stats_results_size); - return -ENOMEM; + wma_handle->link_stats_results = + vos_mem_malloc(link_stats_results_size); + if (NULL == wma_handle->link_stats_results) { + WMA_LOGD("%s: could not allocate mem for stats results-len %zu", + __func__, link_stats_results_size); + return -ENOMEM; + } + vos_mem_zero(wma_handle->link_stats_results, + link_stats_results_size); } link_stats_results = wma_handle->link_stats_results; + + results = (u_int8_t *)link_stats_results->results; + rs_results = (tSirWifiRadioStat *) &results[0]; if (link_stats_results->num_radio == 0) { link_stats_results->num_radio = fixed_param->num_radio; } else if (link_stats_results->num_radio < fixed_param->num_radio) { @@ -5454,19 +5462,16 @@ static int wma_unified_link_radio_stats_event_handler(void *handle, * events may be spoofed. Drop all of them and report error. */ WMA_LOGE("Invalid following WMI_RADIO_LINK_STATS_EVENTID. Discarding this set"); - rs_results->tx_time_per_power_level = NULL; vos_mem_free(wma_handle->link_stats_results); wma_handle->link_stats_results = NULL; vos_mem_free(rs_results->tx_time_per_power_level); + rs_results->tx_time_per_power_level = NULL; return -EINVAL; } - vos_mem_zero(link_stats_results, link_stats_results_size); - link_stats_results->paramId = WMI_LINK_STATS_RADIO; link_stats_results->rspId = fixed_param->request_id; link_stats_results->ifaceId = 0; - link_stats_results->num_radio = fixed_param->num_radio; link_stats_results->peer_event_number = 0; /* @@ -5479,11 +5484,9 @@ static int wma_unified_link_radio_stats_event_handler(void *handle, */ link_stats_results->moreResultToFollow = fixed_param->more_radio_events; - results = (u_int8_t *)link_stats_results->results; t_radio_stats = (u_int8_t *)radio_stats; t_channel_stats = (u_int8_t *)channel_stats; - rs_results = (tSirWifiRadioStat *) &results[0]; rs_results->radio = radio_stats->radio_id; rs_results->onTime = radio_stats->on_time; rs_results->txTime = radio_stats->tx_time; |
