From e1b14d8b1aa82cc45c6a8f64acd76e7bad80c327 Mon Sep 17 00:00:00 2001 From: Dundi Raviteja Date: Mon, 21 Dec 2020 13:00:09 +0530 Subject: [PATCH] qcacld-3.0: Reduce stack frame size in lim_send_probe_req_mgmt_frame Reduce stack frame size of lim_send_probe_req_mgmt_frame() by allocating dynamic memory to tDot11fProbeRequest. Change-Id: Ide3047df132514a1684ec3b3cc0bbd01712ecab3 CRs-Fixed: 2847119 --- .../src/pe/lim/lim_send_management_frames.c | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/core/mac/src/pe/lim/lim_send_management_frames.c b/core/mac/src/pe/lim/lim_send_management_frames.c index 724353516a66..0b6592d6bc7b 100644 --- a/core/mac/src/pe/lim/lim_send_management_frames.c +++ b/core/mac/src/pe/lim/lim_send_management_frames.c @@ -176,7 +176,7 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, uint16_t *additional_ielen, uint8_t *additional_ie) { - tDot11fProbeRequest pr; + tDot11fProbeRequest *pr; uint32_t status, bytes, payload; uint8_t *frame; void *packet; @@ -226,13 +226,16 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, if (pesession) vdev_id = pesession->vdev_id; + pr = qdf_mem_malloc(sizeof(*pr)); + if (!pr) + return QDF_STATUS_E_NOMEM; + /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */ /* and then hand it off to 'dot11f_pack_probe_request' (for */ - /* serialization). We start by zero-initializing the structure: */ - qdf_mem_zero((uint8_t *) &pr, sizeof(pr)); + /* serialization). */ /* & delegating to assorted helpers: */ - populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID); + populate_dot11f_ssid(mac_ctx, ssid, &pr->SSID); if (addn_ielen && additional_ie) p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen); @@ -247,15 +250,15 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, * In the below API pass channel number > 14, do that it fills * only 11a rates in supported rates */ - populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates, + populate_dot11f_supp_rates(mac_ctx, 15, &pr->SuppRates, pesession); } else { populate_dot11f_supp_rates(mac_ctx, channel, - &pr.SuppRates, pesession); + &pr->SuppRates, pesession); if (MLME_DOT11_MODE_11B != dot11mode) { populate_dot11f_ext_supp_rates1(mac_ctx, channel, - &pr.ExtSuppRates); + &pr->ExtSuppRates); } } @@ -265,20 +268,21 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, * RRM is enabled. It should be ok even if we add it into probe req when * RRM is not enabled. */ - populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel); + populate_dot11f_ds_params(mac_ctx, &pr->DSParams, channel); /* Call RRM module to get the tx power for management used. */ txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession); - populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0); + populate_dot11f_wfatpc(mac_ctx, &pr->WFATPC, txPower, 0); if (pesession) { /* Include HT Capability IE */ if (pesession->htCapability && !(WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq))) - populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps); + populate_dot11f_ht_caps(mac_ctx, pesession, + &pr->HTCaps); } else { /* !pesession */ if (IS_DOT11_MODE_HT(dot11mode) && !(WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq))) - populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps); + populate_dot11f_ht_caps(mac_ctx, NULL, &pr->HTCaps); } /* @@ -288,11 +292,11 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, if (wlan_reg_is_24ghz_ch_freq(chan_freq)) { if (mac_ctx->roam.configParam.channelBondingMode24GHz == PHY_SINGLE_CHANNEL_CENTERED) { - pr.HTCaps.supportedChannelWidthSet = + pr->HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ; - pr.HTCaps.shortGI40MHz = 0; + pr->HTCaps.shortGI40MHz = 0; } else { - pr.HTCaps.supportedChannelWidthSet = + pr->HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_40MHZ; } } @@ -301,27 +305,27 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, if (pesession->vhtCapability && !(WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq))) { populate_dot11f_vht_caps(mac_ctx, pesession, - &pr.VHTCaps); + &pr->VHTCaps); is_vht_enabled = true; } } else { if (IS_DOT11_MODE_VHT(dot11mode) && !(WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq))) { populate_dot11f_vht_caps(mac_ctx, pesession, - &pr.VHTCaps); + &pr->VHTCaps); is_vht_enabled = true; } } if (pesession) - populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap, - pesession); + populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr->ExtCap, + pesession); if (IS_DOT11_MODE_HE(dot11mode) && pesession) lim_update_session_he_capable(mac_ctx, pesession); - populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap); + populate_dot11f_he_caps(mac_ctx, pesession, &pr->he_cap); populate_dot11f_he_6ghz_cap(mac_ctx, pesession, - &pr.he_6ghz_band_cap); + &pr->he_6ghz_band_cap); if (addn_ielen && additional_ie) { qdf_mem_zero((uint8_t *)&extracted_ext_cap, @@ -355,11 +359,11 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, if (pesession) { if (!qcn_ie) populate_dot11f_qcn_ie(mac_ctx, pesession, - &pr.qcn_ie, + &pr->qcn_ie, QCN_IE_ATTR_ID_ALL); else populate_dot11f_qcn_ie(mac_ctx, pesession, - &pr.qcn_ie, + &pr->qcn_ie, QCN_IE_ATTR_ID_VHT_MCS11); } @@ -369,10 +373,10 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, * dot11f get packed payload size. */ if (extracted_ext_cap_flag) - lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true); + lim_merge_extcap_struct(&pr->ExtCap, &extracted_ext_cap, true); /* That's it-- now we pack it. First, how much space are we going to */ - status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload); + status = dot11f_get_packed_probe_request_size(mac_ctx, pr, &payload); if (DOT11F_FAILED(status)) { pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)", status); @@ -390,6 +394,7 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, (void **)&packet); if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { pe_err("Failed to allocate %d bytes for a Probe Request", bytes); + qdf_mem_free(pr); return QDF_STATUS_E_NOMEM; } /* Paranoia: */ @@ -400,7 +405,7 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr); /* That done, pack the Probe Request: */ - status = dot11f_pack_probe_request(mac_ctx, &pr, frame + + status = dot11f_pack_probe_request(mac_ctx, pr, frame + sizeof(tSirMacMgmtHdr), payload, &payload); if (DOT11F_FAILED(status)) { @@ -410,6 +415,9 @@ lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx, } else if (DOT11F_WARNED(status)) { pe_warn("There were warnings while packing a Probe Request (0x%08x)", status); } + + qdf_mem_free(pr); + /* Append any AddIE if present. */ if (addn_ielen) { qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,