qcacld-3.0: Use dynamic memory allocation to avoid stack size limit
Due to stack size limit, use dynamic memory allocation instead of
using stack resource.
Change-Id: Icf00bc43718286e1b6239c5e35c6e11964712f8e
CRs-Fixed: 2650690
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index b7260d0..0ba56a9 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -2541,10 +2541,10 @@
int hdd_cfg80211_update_acs_config(struct hdd_adapter *adapter,
uint8_t reason)
{
- struct sk_buff *skb;
+ struct sk_buff *skb = NULL;
struct sap_config *sap_config;
uint32_t channel_count = 0, status = -EINVAL;
- uint32_t freq_list[NUM_CHANNELS] = {0};
+ uint32_t *freq_list;
uint32_t vendor_pcl_list[NUM_CHANNELS] = {0};
uint8_t vendor_weight_list[NUM_CHANNELS] = {0};
struct hdd_vendor_acs_chan_params acs_chan_params;
@@ -2593,6 +2593,10 @@
hdd_get_scan_band(hdd_ctx, &adapter->session.ap.sap_config, &band);
+ freq_list = qdf_mem_malloc(sizeof(uint32_t) * NUM_CHANNELS);
+ if (!freq_list)
+ return -ENOMEM;
+
if (sap_config->acs_cfg.freq_list) {
/* Copy INI or hostapd provided ACS channel range*/
for (i = 0; i < sap_config->acs_cfg.ch_list_count; i++)
@@ -2609,8 +2613,10 @@
sap_config->channel_info = qdf_mem_malloc(
sizeof(struct hdd_channel_info) *
channel_count);
- if (!sap_config->channel_info)
- return -ENOMEM;
+ if (!sap_config->channel_info) {
+ status = -ENOMEM;
+ goto fail;
+ }
hdd_update_reg_chan_info(adapter, channel_count, freq_list);
@@ -2623,8 +2629,8 @@
len, id, GFP_KERNEL);
if (!skb) {
hdd_err("cfg80211_vendor_event_alloc failed");
- qdf_mem_free(sap_config->channel_info);
- return -ENOMEM;
+ status = -ENOMEM;
+ goto fail;
}
/*
* Application expects pcl to be a subset of channel list
@@ -2703,11 +2709,14 @@
goto fail;
cfg80211_vendor_event(skb, GFP_KERNEL);
+ qdf_mem_free(freq_list);
qdf_mem_free(sap_config->channel_info);
return 0;
fail:
- qdf_mem_free(sap_config->channel_info);
+ qdf_mem_free(freq_list);
+ if (sap_config->channel_info)
+ qdf_mem_free(sap_config->channel_info);
if (skb)
kfree_skb(skb);
return status;