From de410b77d32076a8dd51012fe1c1a1c5fb08e4c3 Mon Sep 17 00:00:00 2001 From: Abhishek Singh Date: Mon, 22 May 2017 15:25:39 +0530 Subject: [PATCH] qcacld-3.0: Use memory passed by caller in u_mac_post_ctrl_msg Caller pass an allocated memory to u_mac_post_ctrl_msg, but memory is again allocated in u_mac_post_ctrl_msg before passing it to message queue. This change remove this duplicate mem allocation and use the memory passed by the caller. Change-Id: I4d329c5883832bb6571d1e81f0d9b9a044ebb6d9 CRs-Fixed: 2050449 --- core/sme/src/common/sme_api.c | 18 +++++++++++------- core/wma/src/wlan_qct_wma_legacy.c | 15 ++------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 2ddae73216f3..aeda7d82f0e8 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -1284,7 +1284,7 @@ static void sme_process_ready_to_ext_wow(tHalHandle hHal, --------------------------------------------------------------------------*/ QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal) { - tSirSmeReadyReq Msg; + tSirSmeReadyReq *msg; QDF_STATUS status = QDF_STATUS_E_FAILURE; tpAniSirGlobal pMac = PMAC_STRUCT(hHal); @@ -1292,13 +1292,17 @@ QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal) TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0)); do { - Msg.messageType = eWNI_SME_SYS_READY_IND; - Msg.length = sizeof(tSirSmeReadyReq); - Msg.add_bssdescr_cb = csr_scan_process_single_bssdescr; - Msg.csr_roam_synch_cb = csr_roam_synch_callback; + msg = qdf_mem_malloc(sizeof(*msg)); + if (!msg) { + sme_err("Memory allocation failed! for msg"); + return QDF_STATUS_E_NOMEM; + } + msg->messageType = eWNI_SME_SYS_READY_IND; + msg->length = sizeof(*msg); + msg->add_bssdescr_cb = csr_scan_process_single_bssdescr; + msg->csr_roam_synch_cb = csr_roam_synch_callback; - - if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *) &Msg)) { + if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *) msg)) { status = QDF_STATUS_SUCCESS; } else { sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND"); diff --git a/core/wma/src/wlan_qct_wma_legacy.c b/core/wma/src/wlan_qct_wma_legacy.c index dd15d0915d73..d8addd73a67c 100644 --- a/core/wma/src/wlan_qct_wma_legacy.c +++ b/core/wma/src/wlan_qct_wma_legacy.c @@ -111,20 +111,10 @@ tSirRetStatus u_mac_post_ctrl_msg(void *pSirGlobal, tSirMbMsg *pMb) struct scheduler_msg msg = {0}; tSirRetStatus status = eSIR_SUCCESS; tpAniSirGlobal pMac = (tpAniSirGlobal) pSirGlobal; - tSirMbMsg *pMbLocal; msg.type = pMb->type; msg.bodyval = 0; - - pMbLocal = qdf_mem_malloc(pMb->msgLen); - if (!pMbLocal) { - WMA_LOGE("Memory allocation failed! Can't send 0x%x\n", - msg.type); - return eSIR_MEM_ALLOC_FAILED; - } - - qdf_mem_copy((void *)pMbLocal, (void *)pMb, pMb->msgLen); - msg.bodyptr = pMbLocal; + msg.bodyptr = pMb; switch (msg.type & HAL_MMH_MB_MSG_TYPE_MASK) { case WMA_MSG_TYPES_BEGIN: /* Posts a message to the HAL MsgQ */ @@ -176,13 +166,12 @@ QDF_STATUS umac_send_mb_message_to_mac(void *pBuf) if (NULL == hHal) { QDF_TRACE(QDF_MODULE_ID_SYS, QDF_TRACE_LEVEL_ERROR, "%s: invalid hHal", __func__); + qdf_mem_free(pBuf); } else { sirStatus = u_mac_post_ctrl_msg(hHal, pBuf); if (eSIR_SUCCESS == sirStatus) qdf_ret_status = QDF_STATUS_SUCCESS; } - qdf_mem_free(pBuf); - return qdf_ret_status; }