From 03bd5ad0ace3d3e8a3efc4a46e854e4038ae565f Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Wed, 19 Feb 2014 17:43:45 +0530 Subject: qcacld: Fix kmemleak warnings Fix possible memory leak in the memory allocated for power save configuration for device which does not have power save offloaded. Move the allocation under !psOffloadEnable check to make sure the memory is not allocated only when it is needed. Change-Id: Idd7a3ca063c255755ef82dbeba333aa42874f53b CRs-Fixed: 607843 --- CORE/MAC/src/pe/lim/limApi.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/CORE/MAC/src/pe/lim/limApi.c b/CORE/MAC/src/pe/lim/limApi.c index 785fe1c61bef..c64b1ed57dbc 100644 --- a/CORE/MAC/src/pe/lim/limApi.c +++ b/CORE/MAC/src/pe/lim/limApi.c @@ -580,31 +580,31 @@ static tSirRetStatus __limInitConfig( tpAniSirGlobal pMac ) /* WNI_CFG_MAX_PS_POLL */ - /* Allocate and fill in power save configuration. */ - pPowerSaveConfig = vos_mem_malloc(sizeof(tSirPowerSaveCfg)); - if (NULL == pPowerSaveConfig) - { - PELOGE(limLog(pMac, LOGE, FL("LIM: Cannot allocate memory for power save " - "configuration"));) - return eSIR_FAILURE; - } - - /* This context should be valid if power-save configuration message has been - * already dispatched during initialization process. Re-using the present - * configuration mask - */ if (!pMac->psOffloadEnabled) { - vos_mem_copy(pPowerSaveConfig, (tANI_U8 *)&pMac->pmm.gPmmCfg, + /* Allocate and fill in power save configuration. */ + pPowerSaveConfig = vos_mem_malloc(sizeof(tSirPowerSaveCfg)); + if (NULL == pPowerSaveConfig) + { + PELOGE(limLog(pMac, LOGE, + FL("LIM: Cannot allocate memory for power save configuration"));) + return eSIR_FAILURE; + } + + /* This context should be valid if power-save configuration message has + * been already dispatched during initialization process. Re-using the + * present configuration mask + */ + vos_mem_copy(pPowerSaveConfig, (tANI_U8 *)&pMac->pmm.gPmmCfg, sizeof(tSirPowerSaveCfg)); - /* Note: it is okay to do this since DAL/HAL is alrady started */ - if ( (pmmSendPowerSaveCfg(pMac, pPowerSaveConfig)) != eSIR_SUCCESS) - { - PELOGE(limLog(pMac, LOGE, + /* Note: it is okay to do this since DAL/HAL is alrady started */ + if ( (pmmSendPowerSaveCfg(pMac, pPowerSaveConfig)) != eSIR_SUCCESS) + { + PELOGE(limLog(pMac, LOGE, FL("LIM: pmmSendPowerSaveCfg() failed "));) - return eSIR_FAILURE; - } + return eSIR_FAILURE; + } } /* WNI_CFG_BG_SCAN_CHANNEL_LIST_CHANNEL_LIST */ -- cgit v1.2.3