qcacld-3.0: Free allocated memory in wma_unified_link_radio_stats_event_handler
In the file wma_unified_radio_tx_power_level_stats_event_handler ,
the driver allocates memory to rs_results->tx_time_per_power_level ,
also in api wma_unified_link_radio_stats_event_handler ,
rs_results->channels , without checking a previous allocated
memory for the same . Also the driver makes the pointers
rs_results->tx_time_per_power_level and rs_results->channels
as null without a prior check , which results in a memory leak.
Fix is to add a check for rs_results->channels and
rs_results->tx_time_per_power_level for NULL , and free
the already allocated memory for the same.
Change-Id: I02af53454270239bf68446a727b735c8ef10d434
CRs-Fixed: 2150714
diff --git a/core/wma/src/wma_utils.c b/core/wma/src/wma_utils.c
index a2ce9b1..2d4ebf0 100644
--- a/core/wma/src/wma_utils.c
+++ b/core/wma/src/wma_utils.c
@@ -1706,12 +1706,17 @@
rs_results->onTimePnoScan = radio_stats->on_time_pno_scan;
rs_results->onTimeHs20 = radio_stats->on_time_hs20;
rs_results->total_num_tx_power_levels = 0;
- rs_results->tx_time_per_power_level = NULL;
+ 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;
+ }
+ if (rs_results->channels) {
+ qdf_mem_free(rs_results->channels);
+ rs_results->channels = NULL;
+ }
rs_results->numChannels = radio_stats->num_channels;
rs_results->on_time_host_scan = radio_stats->on_time_host_scan;
rs_results->on_time_lpi_scan = radio_stats->on_time_lpi_scan;
- rs_results->channels = NULL;
-
if (rs_results->numChannels) {
rs_results->channels = (tSirWifiChannelStats *) qdf_mem_malloc(
radio_stats->num_channels *