diff options
| author | Deepak Dhamdhere <ddhamdhe@codeaurora.org> | 2017-02-28 13:35:52 -0800 |
|---|---|---|
| committer | qcabuildsw <qcabuildsw@localhost> | 2017-03-07 16:23:03 -0800 |
| commit | e596030d106678b2b79403f964a6d1fcdf96de13 (patch) | |
| tree | 979f30b90c7c4bbefeccc7ab08ac8719e1e6ff91 | |
| parent | 4ed3c787ab22ef54064f4040288535d03ea173fb (diff) | |
qcacld-3.0: Add a function to free fields of saved scan command
saved_scan_cmd has many fields that are allocated separately during
profile save operations. Add a routine to free those memory objects,
release the profile and avoid memory leaks.
CRs-Fixed: 2012430
Change-Id: I0d9fcb29ca7f8290692ba4b688ffe025d5b5d747
| -rw-r--r-- | core/sme/src/csr/csr_api_scan.c | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/core/sme/src/csr/csr_api_scan.c b/core/sme/src/csr/csr_api_scan.c index 57f0645107ed..80565aa5c38f 100644 --- a/core/sme/src/csr/csr_api_scan.c +++ b/core/sme/src/csr/csr_api_scan.c @@ -3947,6 +3947,37 @@ csr_diag_scan_complete(tpAniSirGlobal pMac, #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */ /** + * csr_saved_scan_cmd_free_fields() - Free internal fields of scan command + * + * @mac_ctx: Global MAC context + * @saved_scan_cmd: Pointer to scan command + * + * Frees data structures allocated inside saved_scan_cmd and releases + * the profile. + * Return: None + */ + +static void csr_saved_scan_cmd_free_fields(tpAniSirGlobal mac_ctx, + tSmeCmd *saved_scan_cmd) +{ + if (saved_scan_cmd->u.scanCmd.pToRoamProfile) { + csr_release_profile(mac_ctx, + saved_scan_cmd->u.scanCmd.pToRoamProfile); + qdf_mem_free(saved_scan_cmd->u.scanCmd.pToRoamProfile); + saved_scan_cmd->u.scanCmd.pToRoamProfile = NULL; + } + if (saved_scan_cmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList) { + qdf_mem_free(saved_scan_cmd->u.scanCmd.u. + scanRequest.SSIDs.SSIDList); + saved_scan_cmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList = NULL; + } + if (saved_scan_cmd->u.roamCmd.pRoamBssEntry) { + qdf_mem_free(saved_scan_cmd->u.roamCmd.pRoamBssEntry); + saved_scan_cmd->u.roamCmd.pRoamBssEntry = NULL; + } +} + +/** * csr_save_profile() - Save the profile info from sme command * @mac_ctx: Global MAC context * @save_cmd: Pointer where the command will be saved @@ -4039,15 +4070,7 @@ static QDF_STATUS csr_save_profile(tpAniSirGlobal mac_ctx, error: csr_scan_handle_search_for_ssid_failure(mac_ctx, command); - if (save_cmd->u.roamCmd.pRoamBssEntry) - qdf_mem_free(save_cmd->u.roamCmd.pRoamBssEntry); - if (save_cmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList) - qdf_mem_free(save_cmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList); - if (save_cmd->u.scanCmd.pToRoamProfile) { - csr_release_profile(mac_ctx, - save_cmd->u.scanCmd.pToRoamProfile); - qdf_mem_free(save_cmd->u.scanCmd.pToRoamProfile); - } + csr_saved_scan_cmd_free_fields(mac_ctx, save_cmd); return QDF_STATUS_E_FAILURE; } @@ -4127,26 +4150,8 @@ csr_handle_nxt_cmd(tpAniSirGlobal mac_ctx, tSmeCmd *pCommand, chan, pCommand->sessionId, ret); saved_scan_cmd = (tSmeCmd *)mac_ctx->sme.saved_scan_cmd; if (saved_scan_cmd) { - csr_release_profile(mac_ctx, saved_scan_cmd->u.scanCmd. - pToRoamProfile); - if (saved_scan_cmd->u.scanCmd.pToRoamProfile) { - qdf_mem_free(saved_scan_cmd->u.scanCmd. - pToRoamProfile); - saved_scan_cmd->u.scanCmd. - pToRoamProfile = NULL; - } - if (saved_scan_cmd->u.scanCmd.u.scanRequest.SSIDs. - SSIDList) { - qdf_mem_free(saved_scan_cmd->u.scanCmd.u. - scanRequest.SSIDs.SSIDList); - saved_scan_cmd->u.scanCmd.u.scanRequest.SSIDs. - SSIDList = NULL; - } - if (saved_scan_cmd->u.roamCmd.pRoamBssEntry) { - qdf_mem_free(saved_scan_cmd->u.roamCmd. - pRoamBssEntry); - saved_scan_cmd->u.roamCmd.pRoamBssEntry = NULL; - } + csr_saved_scan_cmd_free_fields(mac_ctx, + saved_scan_cmd); qdf_mem_free(saved_scan_cmd); saved_scan_cmd = NULL; sms_log(mac_ctx, LOGE, @@ -4176,6 +4181,8 @@ error: csr_scan_handle_search_for_ssid_failure(mac_ctx, pCommand); if (mac_ctx->sme.saved_scan_cmd) { + csr_saved_scan_cmd_free_fields(mac_ctx, + mac_ctx->sme.saved_scan_cmd); qdf_mem_free(mac_ctx->sme.saved_scan_cmd); mac_ctx->sme.saved_scan_cmd = NULL; } @@ -4184,6 +4191,8 @@ error: sms_log(mac_ctx, LOGE, FL("conn update ret %d"), ret); csr_scan_handle_search_for_ssid(mac_ctx, pCommand); if (mac_ctx->sme.saved_scan_cmd) { + csr_saved_scan_cmd_free_fields(mac_ctx, + mac_ctx->sme.saved_scan_cmd); qdf_mem_free(mac_ctx->sme.saved_scan_cmd); mac_ctx->sme.saved_scan_cmd = NULL; } |
