From b739a246ebaac4e1c682ffe3655844b01793965b Mon Sep 17 00:00:00 2001 From: Rakesh Sunki Date: Thu, 9 Oct 2014 13:19:04 -0700 Subject: qcacld: Fix memory leak during scan process Remove the double allocation of memroy for BSSID and channelList of the scan profile. Allocate the memory for BSSID and channelList only if it is not allocated earlier from copy profile routine. Change-Id: I0ed8afb942f87dc8f5319dae5e5193a1117a5344 CRs-Fixed: 735259 --- CORE/SME/src/csr/csrNeighborRoam.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/CORE/SME/src/csr/csrNeighborRoam.c b/CORE/SME/src/csr/csrNeighborRoam.c index 283417bfb9c2..d5662e3ad7ae 100644 --- a/CORE/SME/src/csr/csrNeighborRoam.c +++ b/CORE/SME/src/csr/csrNeighborRoam.c @@ -5922,12 +5922,17 @@ eHalStatus csrNeighborRoamProcessHandoffReq(tpAniSirGlobal pMac, //Add the BSSID & Channel pProfile->BSSIDs.numOfBSSIDs = 1; - pProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pProfile->BSSIDs.numOfBSSIDs); + if (NULL == pProfile->BSSIDs.bssid) { - smsLog(pMac, LOGE, FL("mem alloc failed for BSSID")); - status = eHAL_STATUS_FAILURE; - break; + pProfile->BSSIDs.bssid = + vos_mem_malloc(sizeof(tSirMacAddr) * pProfile->BSSIDs.numOfBSSIDs); + if (NULL == pProfile->BSSIDs.bssid) + { + smsLog(pMac, LOGE, FL("mem alloc failed for BSSID")); + status = eHAL_STATUS_FAILURE; + break; + } } vos_mem_zero(pProfile->BSSIDs.bssid, sizeof(tSirMacAddr) * pProfile->BSSIDs.numOfBSSIDs); @@ -5940,14 +5945,17 @@ eHalStatus csrNeighborRoamProcessHandoffReq(tpAniSirGlobal pMac, } pProfile->ChannelInfo.numOfChannels = 1; - pProfile->ChannelInfo.ChannelList = - vos_mem_malloc(sizeof(*pProfile->ChannelInfo.ChannelList) * - pProfile->ChannelInfo.numOfChannels); if (NULL == pProfile->ChannelInfo.ChannelList) { - smsLog(pMac, LOGE, FL("mem alloc failed for ChannelList")); - status = eHAL_STATUS_FAILURE; - break; + pProfile->ChannelInfo.ChannelList = + vos_mem_malloc(sizeof(*pProfile->ChannelInfo.ChannelList) * + pProfile->ChannelInfo.numOfChannels); + if (NULL == pProfile->ChannelInfo.ChannelList) + { + smsLog(pMac, LOGE, FL("mem alloc failed for ChannelList")); + status = eHAL_STATUS_FAILURE; + break; + } } pProfile->ChannelInfo.ChannelList[0] = pNeighborRoamInfo->handoffReqInfo.channel; -- cgit v1.2.3