From e2f6771896db7208b593f8eb9b5ae49b79aaa368 Mon Sep 17 00:00:00 2001 From: Bala Venkatesh Date: Mon, 3 Jun 2019 19:55:45 +0530 Subject: [PATCH] qcacld-3.0: Avoid memory leaks pScanFilter->BSSIDs.numOfBSSIDs is allocated as part of function csr_neighbor_roam_prepare_scan_profile_filter and this memory is not freed in error cases. Hence free the allocated memory of pScanFilter->BSSIDs.numOfBSSIDs in error cases before returning from function csr_neighbor_roam_prepare_scan_profile_filter. Change-Id: I411dba7ead796f84994e633a387730de6ee4d579 CRs-Fixed: 2464822 --- core/sme/src/csr/csr_neighbor_roam.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/sme/src/csr/csr_neighbor_roam.c b/core/sme/src/csr/csr_neighbor_roam.c index b6b41fb8b562..8eacf1063ea7 100644 --- a/core/sme/src/csr/csr_neighbor_roam.c +++ b/core/sme/src/csr/csr_neighbor_roam.c @@ -384,8 +384,11 @@ csr_neighbor_roam_prepare_scan_profile_filter(struct mac_context *mac, pScanFilter->SSIDs.SSIDList = qdf_mem_malloc(sizeof(tCsrSSIDInfo) * pScanFilter->SSIDs.numOfSSIDs); - if (!pScanFilter->SSIDs.SSIDList) + if (!pScanFilter->SSIDs.SSIDList) { + qdf_mem_free(pScanFilter->BSSIDs.bssid); + pScanFilter->BSSIDs.bssid = NULL; return QDF_STATUS_E_NOMEM; + } for (i = 0; i < roam_params->num_ssid_allowed_list; i++) { pScanFilter->SSIDs.SSIDList[i].handoffPermitted = 1; @@ -402,8 +405,11 @@ csr_neighbor_roam_prepare_scan_profile_filter(struct mac_context *mac, pScanFilter->SSIDs.numOfSSIDs = 1; pScanFilter->SSIDs.SSIDList = qdf_mem_malloc(sizeof(tCsrSSIDInfo)); - if (!pScanFilter->SSIDs.SSIDList) + if (!pScanFilter->SSIDs.SSIDList) { + qdf_mem_free(pScanFilter->BSSIDs.bssid); + pScanFilter->BSSIDs.bssid = NULL; return QDF_STATUS_E_NOMEM; + } pScanFilter->SSIDs.SSIDList->handoffPermitted = 1; pScanFilter->SSIDs.SSIDList->ssidHidden = 0; @@ -442,6 +448,8 @@ csr_neighbor_roam_prepare_scan_profile_filter(struct mac_context *mac, pScanFilter->ChannelInfo.ChannelList = qdf_mem_malloc(num_ch * sizeof(uint8_t)); if (!pScanFilter->ChannelInfo.ChannelList) { + qdf_mem_free(pScanFilter->BSSIDs.bssid); + pScanFilter->BSSIDs.bssid = NULL; qdf_mem_free(pScanFilter->SSIDs.SSIDList); pScanFilter->SSIDs.SSIDList = NULL; return QDF_STATUS_E_NOMEM;