diff options
| author | Mahesh Kumar Kalikot Veetil <mkalikot@qca.qualcomm.com> | 2015-07-09 15:43:02 -0700 |
|---|---|---|
| committer | Anjaneedevi Kapparapu <akappa@codeaurora.org> | 2015-07-20 16:23:55 +0530 |
| commit | 702fe220cd89f996efd9577bcc8f5e14e10ebbf4 (patch) | |
| tree | e7926c97bae81437dc0309ea953e96ad00c33568 | |
| parent | 3159bc3520b9d904b4acf926b1f3443b4fe452be (diff) | |
qcacld: Fix a memory leak in WDA_SET_THERMAL_LEVEL
Use message bodyval to pass thermal level which is of type uint8. This
avoids any memory leak and pass the thermal level in an optimum way.
Change-Id: Ie4dfaac68e17ac2a0d2a3433d8595a928ca66ea8
CRs-fixed: 869091
| -rw-r--r-- | CORE/SERVICES/WMA/wma.c | 37 | ||||
| -rw-r--r-- | CORE/SME/src/sme_common/sme_Api.c | 65 |
2 files changed, 45 insertions, 57 deletions
diff --git a/CORE/SERVICES/WMA/wma.c b/CORE/SERVICES/WMA/wma.c index 0cf6efed8dcd..ab5c531d7210 100644 --- a/CORE/SERVICES/WMA/wma.c +++ b/CORE/SERVICES/WMA/wma.c @@ -22224,29 +22224,28 @@ static void wma_set_thermal_level_ind(u_int8_t level) WMA_LOGE(FL("Fail to post set temperaturml level ind msg")); } -/* function : wma_process_set_thermal_level - * Description : This function set the new thermal throttle level in the - txrx module and sends down the corresponding temperature - thresholds to the firmware - * Args : - wma : Pointer to WMA handle - * pThermalLevel : Pointer to thermal level - * Returns : - * VOS_STATUS_SUCCESS for success otherwise failure +/** + * wma_process_set_thermal_level() - Sets new thermal throttle level + * wma: Pointer to wma handle + * thermal_level: Thermal level to set + * + * This function sets new thermal throttle level in the txrx module and sends + * down the corresponding temperature thresholds to the firmware. + * + * Return: VOS_STATUS_SUCCESS for success otherwise failure. + * */ VOS_STATUS wma_process_set_thermal_level(tp_wma_handle wma, - u_int8_t *pThermalLevel) + uint8_t thermal_level) { - u_int8_t thermal_level; ol_txrx_pdev_handle curr_pdev; - if (NULL == wma || NULL == pThermalLevel) { - WMA_LOGE("TM Invalid input"); - return VOS_STATUS_E_FAILURE; - } + if (NULL == wma) { + WMA_LOGE("TM Invalid input"); + return VOS_STATUS_E_FAILURE; + } - thermal_level = (*pThermalLevel); curr_pdev = vos_get_context(VOS_MODULE_ID_TXRX, wma->vos_context); if (NULL == curr_pdev) { @@ -22258,7 +22257,7 @@ VOS_STATUS wma_process_set_thermal_level(tp_wma_handle wma, /* Check if thermal mitigation is enabled */ if (!wma->thermal_mgmt_info.thermalMgmtEnabled) { - WMA_LOGE("Thermal mgmt is not enabled, ignoring set level command"); + WMA_LOGE("Thermal mgmt is not enabled, ignoring set level cmd"); return VOS_STATUS_E_FAILURE; } @@ -22269,7 +22268,7 @@ VOS_STATUS wma_process_set_thermal_level(tp_wma_handle wma, if (thermal_level == wma->thermal_mgmt_info.thermalCurrLevel) { WMA_LOGD("Current level %d is same as the set level, ignoring", - wma->thermal_mgmt_info.thermalCurrLevel); + wma->thermal_mgmt_info.thermalCurrLevel); return VOS_STATUS_SUCCESS; } @@ -25727,7 +25726,7 @@ VOS_STATUS wma_mc_process_msg(v_VOID_t *vos_context, vos_msg_t *msg) break; case WDA_SET_THERMAL_LEVEL: - wma_process_set_thermal_level(wma_handle, (u_int8_t *) msg->bodyptr); + wma_process_set_thermal_level(wma_handle, msg->bodyval); break; case WDA_INIT_BAD_PEER_TX_CTL_INFO_CMD: diff --git a/CORE/SME/src/sme_common/sme_Api.c b/CORE/SME/src/sme_common/sme_Api.c index 9283987a3df9..993e7ed2942d 100644 --- a/CORE/SME/src/sme_common/sme_Api.c +++ b/CORE/SME/src/sme_common/sme_Api.c @@ -14015,50 +14015,39 @@ void sme_add_set_thermal_level_callback(tHalHandle hHal, pMac->sme.set_thermal_level_cb = callback; } -/* --------------------------------------------------------------------------- - \fn sme_SetThermalLevel - \brief SME API to set the thermal mitigation level - \param hHal - \param level : thermal mitigation level - \- return eHalStatus - -------------------------------------------------------------------------*/ +/** + * sme_SetThermalLevel() - SME API to set the thermal mitigation level + * hHal: Handler to HAL + * level: Thermal mitigation level + * + * Return: HAL status code + */ eHalStatus sme_SetThermalLevel( tHalHandle hHal, tANI_U8 level ) { - vos_msg_t msg; - tpAniSirGlobal pMac = PMAC_STRUCT(hHal); - u_int8_t *pLevel = vos_mem_malloc(sizeof(*pLevel)); + vos_msg_t msg; + tpAniSirGlobal pMac = PMAC_STRUCT(hHal); + VOS_STATUS vosStatus = VOS_STATUS_SUCCESS; - if (NULL == pLevel) - { - VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, - "%s: could not allocate pLevel", __func__); - return eHAL_STATUS_E_MALLOC_FAILED; - } + if (eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock(&pMac->sme)) { + vos_mem_set(&msg, sizeof(msg), 0); + msg.type = WDA_SET_THERMAL_LEVEL; + msg.bodyval = level; - *pLevel = level; + vosStatus = vos_mq_post_message(VOS_MODULE_ID_WDA, &msg); + if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { + VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, + "%s: Not able to post WDA_SET_THERMAL_LEVEL to WDA!", + __func__); + sme_ReleaseGlobalLock(&pMac->sme); + return eHAL_STATUS_FAILURE; + } + sme_ReleaseGlobalLock(&pMac->sme); + return eHAL_STATUS_SUCCESS; + } + return eHAL_STATUS_FAILURE; +} - if (eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock(&pMac->sme)) - { - msg.type = WDA_SET_THERMAL_LEVEL; - msg.reserved = 0; - msg.bodyptr = pLevel; - if (!VOS_IS_STATUS_SUCCESS( - vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))) - { - VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, - "%s: Not able to post WDA_SET_THERMAL_LEVEL to WDA!", - __func__); - vos_mem_free(pLevel); - sme_ReleaseGlobalLock(&pMac->sme); - return eHAL_STATUS_FAILURE; - } - sme_ReleaseGlobalLock(&pMac->sme); - return eHAL_STATUS_SUCCESS; - } - vos_mem_free(pLevel); - return eHAL_STATUS_FAILURE; -} /* --------------------------------------------------------------------------- \fn sme_TxpowerLimit \brief SME API to set txpower limits |
