summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJingxiang Ge <quic_jge@quicinc.com>2021-12-02 15:59:01 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2021-12-29 23:13:32 -0800
commitc858fbc8b8fadb26e09c0133d3dd360c8c84ef04 (patch)
treea6517cd6981bbfff601f47df484e5a2438ebe47d
parentab63644b28389f4fc5bfb8fe61e37f455f712964 (diff)
qcacld-3.0: Fix possible memory leak of tx_time_per_power_level
It is possible tx_time_per_power_level is not freed in last event, and it is reused in __wma_unified_radio_tx_power_level_stats_event_handler, the buffer size may be different for each event by manually test. Fix is to check if memory is freed before malloc, if not null, free it before malloc. Change-Id: I51064734cf97b9ff0ecbbaf27f38d5a223c91d3b CRs-Fixed: 3057436
-rw-r--r--core/wma/src/wma_utils.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/core/wma/src/wma_utils.c b/core/wma/src/wma_utils.c
index af9459c262e0..60f157cbe7f6 100644
--- a/core/wma/src/wma_utils.c
+++ b/core/wma/src/wma_utils.c
@@ -1635,20 +1635,25 @@ static int wma_unified_radio_tx_power_level_stats_event_handler(void *handle,
return -EINVAL;
}
+ if (rs_results->tx_time_per_power_level) {
+ qdf_mem_free(rs_results->tx_time_per_power_level);
+ rs_results->tx_time_per_power_level = NULL;
+ }
+
+ rs_results->tx_time_per_power_level =
+ qdf_mem_malloc(sizeof(uint32_t) *
+ rs_results->total_num_tx_power_levels);
if (!rs_results->tx_time_per_power_level) {
- rs_results->tx_time_per_power_level = qdf_mem_malloc(
- sizeof(uint32_t) *
- rs_results->total_num_tx_power_levels);
- if (!rs_results->tx_time_per_power_level) {
- WMA_LOGA("%s: Mem alloc fail for tx power level stats",
- __func__);
- /* In error case, atleast send the radio stats without
- * tx_power_level stats */
- rs_results->total_num_tx_power_levels = 0;
- link_stats_results->nr_received++;
- goto post_stats;
- }
+ WMA_LOGA("%s: Mem alloc fail for tx power level stats",
+ __func__);
+ /* In error case, atleast send the radio stats without
+ * tx_power_level stats
+ */
+ rs_results->total_num_tx_power_levels = 0;
+ link_stats_results->nr_received++;
+ goto post_stats;
}
+
qdf_mem_copy(&rs_results->tx_time_per_power_level[
fixed_param->power_level_offset],
tx_power_level_values,