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
This commit is contained in:
Bala Venkatesh 2019-06-03 19:55:45 +05:30 • committed by nshrivas
commit e2f6771896

View file

@ -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;