From 157263fe2a9c894b32646070e6fdbb887aa298a5 Mon Sep 17 00:00:00 2001 From: Arif Hussain Date: Wed, 3 Oct 2018 13:07:15 -0700 Subject: [PATCH] qcacld-3.0: wma: Remove excessive logs Below API's logs failure with caller information, So no need logs at caller. qdf_mem_malloc_atomic() qdf_mem_malloc() wmi_buf_alloc() qdf_nbuf_alloc() wmi_unified_cmd_send() Change-Id: I5d7d49811d71f83ecafccd9f936af323073b32c6 CRs-Fixed: 2327098 --- core/wma/src/wma_data.c | 26 +--- core/wma/src/wma_dev_if.c | 42 ++----- core/wma/src/wma_features.c | 238 ++++++++++------------------------- core/wma/src/wma_main.c | 83 ++++-------- core/wma/src/wma_mgmt.c | 2 - core/wma/src/wma_ocb.c | 17 ++- core/wma/src/wma_power.c | 17 +-- core/wma/src/wma_scan_roam.c | 172 ++++++++----------------- core/wma/src/wma_utils.c | 124 ++++++------------ core/wma/src/wma_utils_ut.c | 8 +- 10 files changed, 211 insertions(+), 518 deletions(-) diff --git a/core/wma/src/wma_data.c b/core/wma/src/wma_data.c index 3e3c2bf9dfd3..beb74eed0b1b 100644 --- a/core/wma/src/wma_data.c +++ b/core/wma/src/wma_data.c @@ -2093,11 +2093,8 @@ int wma_ibss_peer_info_event_handler(void *handle, uint8_t *data, WMA_LOGE("%s: num_peers %d", __func__, num_peers); pRsp = qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoRspParams)); - if (NULL == pRsp) { - WMA_LOGE("%s: could not allocate memory for ibss peer info rsp len %zu", - __func__, sizeof(tSirIbssGetPeerInfoRspParams)); + if (!pRsp) return 0; - } /*sanity check */ if (!(num_peers) || (num_peers > 32) || @@ -2901,10 +2898,8 @@ void ol_rx_aggregation_hole(uint32_t hole_info) alloc_len = sizeof(*rx_aggr_hole_event) + sizeof(rx_aggr_hole_event->hole_info_array[0]); rx_aggr_hole_event = qdf_mem_malloc(alloc_len); - if (NULL == rx_aggr_hole_event) { - WMA_LOGE("%s: Memory allocation failure", __func__); + if (!rx_aggr_hole_event) return; - } rx_aggr_hole_event->hole_cnt = 1; rx_aggr_hole_event->hole_info_array[0] = hole_info; @@ -2970,11 +2965,8 @@ void ol_rx_err(void *pdev, uint8_t vdev_id, return; eth_hdr = (struct ether_header *)qdf_nbuf_data(rx_frame); mic_err_ind = qdf_mem_malloc(sizeof(*mic_err_ind)); - if (!mic_err_ind) { - WMA_LOGE("%s: Failed to allocate memory for MIC indication message", - __func__); + if (!mic_err_ind) return; - } mic_err_ind->messageType = eWNI_SME_MIC_FAILURE_IND; mic_err_ind->length = sizeof(*mic_err_ind); @@ -3118,11 +3110,8 @@ wma_indicate_err( } mic_err_ind = qdf_mem_malloc(sizeof(*mic_err_ind)); - if (!mic_err_ind) { - WMA_LOGE("%s: MIC indication mem alloc failed", - __func__); + if (!mic_err_ind) return; - } qdf_mem_set((void *) mic_err_ind, 0, sizeof(*mic_err_ind)); @@ -3210,12 +3199,9 @@ uint8_t wma_rx_invalid_peer_ind(uint8_t vdev_id, void *wh) struct ieee80211_frame *wh_l = (struct ieee80211_frame *)wh; tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA); - rx_inv_msg = (struct ol_rx_inv_peer_params *) - qdf_mem_malloc(sizeof(struct ol_rx_inv_peer_params)); - if (NULL == rx_inv_msg) { - WMA_LOGE("%s: mem alloc failed for rx_data_msg", __func__); + rx_inv_msg = qdf_mem_malloc(sizeof(struct ol_rx_inv_peer_params)); + if (!rx_inv_msg) return -ENOMEM; - } rx_inv_msg->vdev_id = vdev_id; qdf_mem_copy(rx_inv_msg->ra, wh_l->i_addr1, OL_TXRX_MAC_ADDR_LEN); diff --git a/core/wma/src/wma_dev_if.c b/core/wma/src/wma_dev_if.c index 8109d882a5f5..2162ed7f1ac8 100644 --- a/core/wma/src/wma_dev_if.c +++ b/core/wma/src/wma_dev_if.c @@ -535,8 +535,7 @@ static QDF_STATUS wma_self_peer_remove(tp_wma_handle wma_handle, wmi_service_sync_delete_cmds)) { sta_self_wmi_rsp = qdf_mem_malloc(sizeof(struct del_sta_self_rsp_params)); - if (sta_self_wmi_rsp == NULL) { - WMA_LOGE(FL("Failed to allocate memory")); + if (!sta_self_wmi_rsp) { qdf_status = QDF_STATUS_E_NOMEM; goto error; } @@ -992,16 +991,12 @@ static void wma_vdev_start_rsp(tp_wma_handle wma, bcn = wma->interfaces[resp_event->vdev_id].beacon; if (!bcn) { - WMA_LOGE("%s: Failed alloc memory for beacon struct", - __func__); add_bss->status = QDF_STATUS_E_NOMEM; goto send_fail_resp; } bcn->buf = qdf_nbuf_alloc(NULL, SIR_MAX_BEACON_SIZE, 0, sizeof(uint32_t), 0); if (!bcn->buf) { - WMA_LOGE("%s: No memory allocated for beacon buffer", - __func__); qdf_mem_free(bcn); add_bss->status = QDF_STATUS_E_FAILURE; goto send_fail_resp; @@ -3408,9 +3403,7 @@ void wma_hold_req_timer(void *data) WMA_LOGE(FL("set hw mode req timed out")); - if (!params) - WMA_LOGE("%s: Memory allocation failed", __func__); - else { + if (params) { params->status = SET_HW_MODE_STATUS_ECANCELED; params->cfgd_hw_mode_index = 0; params->num_vdev_mac_entries = 0; @@ -3449,11 +3442,8 @@ struct wma_target_req *wma_fill_hold_req(tp_wma_handle wma, QDF_STATUS status; req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - WMA_LOGE(FL("Failed to allocate memory for msg %d vdev %d"), - msg_type, vdev_id); + if (!req) return NULL; - } WMA_LOGD(FL("vdev_id %d msg %d type %d"), vdev_id, msg_type, type); qdf_spin_lock_bh(&wma->wma_hold_req_q_lock); @@ -3800,11 +3790,8 @@ struct wma_target_req *wma_fill_vdev_req(tp_wma_handle wma, QDF_STATUS status; req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - WMA_LOGE("%s: Failed to allocate memory for msg %d vdev %d", - __func__, msg_type, vdev_id); + if (!req) return NULL; - } WMA_LOGD("%s: vdev_id %d msg %d", __func__, vdev_id, msg_type); qdf_spin_lock_bh(&wma->vdev_respq_lock); @@ -4277,10 +4264,9 @@ static void wma_add_bss_sta_mode(tp_wma_handle wma, tpAddBssParams add_bss) if (iface->addBssStaContext) qdf_mem_free(iface->addBssStaContext); iface->addBssStaContext = qdf_mem_malloc(sizeof(tAddStaParams)); - if (!iface->addBssStaContext) { - WMA_LOGE("%s Failed to allocat memory", __func__); + if (!iface->addBssStaContext) goto send_fail_resp; - } + qdf_mem_copy(iface->addBssStaContext, &add_bss->staContext, sizeof(tAddStaParams)); @@ -4291,11 +4277,9 @@ static void wma_add_bss_sta_mode(tp_wma_handle wma, tpAddBssParams add_bss) if (add_bss->extSetStaKeyParamValid) { iface->staKeyParams = qdf_mem_malloc(sizeof(tSetStaKeyParams)); - if (!iface->staKeyParams) { - WMA_LOGE("%s Failed to allocat memory", - __func__); + if (!iface->staKeyParams) goto send_fail_resp; - } + qdf_mem_copy(iface->staKeyParams, &add_bss->extSetStaKeyParam, sizeof(tSetStaKeyParams)); @@ -4886,9 +4870,6 @@ static void wma_add_tdls_sta(tp_wma_handle wma, tpAddStaParams add_sta) peerStateParams = qdf_mem_malloc(sizeof(tTdlsPeerStateParams)); if (!peerStateParams) { - WMA_LOGE - ("%s: Failed to allocate memory for peerStateParams for %pM", - __func__, add_sta->staMac); add_sta->status = QDF_STATUS_E_NOMEM; goto send_rsp; } @@ -5371,8 +5352,6 @@ static void wma_del_tdls_sta(tp_wma_handle wma, tpDeleteStaParams del_sta) peerStateParams = qdf_mem_malloc(sizeof(tTdlsPeerStateParams)); if (!peerStateParams) { - WMA_LOGE("%s: Failed to allocate memory for peerStateParams for: %pM", - __func__, del_sta->staMac); del_sta->status = QDF_STATUS_E_NOMEM; goto send_del_rsp; } @@ -6024,11 +6003,8 @@ int wma_fill_beacon_interval_reset_req(tp_wma_handle wma, uint8_t vdev_id, struct wma_beacon_interval_reset_req *req; req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - WMA_LOGE("%s: Failed to allocate memory for beacon_interval_reset_req vdev %d", - __func__, vdev_id); + if (!req) return -ENOMEM; - } WMA_LOGD("%s: vdev_id %d ", __func__, vdev_id); req->vdev_id = vdev_id; diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c index 512e54b7ac8e..cc2649fcebe5 100644 --- a/core/wma/src/wma_features.c +++ b/core/wma/src/wma_features.c @@ -186,12 +186,9 @@ static int wma_wake_reason_auto_shutdown(void) QDF_STATUS qdf_status; struct scheduler_msg sme_msg = { 0 }; - auto_sh_evt = (tSirAutoShutdownEvtParams *) - qdf_mem_malloc(sizeof(tSirAutoShutdownEvtParams)); - if (!auto_sh_evt) { - WMA_LOGE(FL("No Mem")); + auto_sh_evt = qdf_mem_malloc(sizeof(tSirAutoShutdownEvtParams)); + if (!auto_sh_evt) return -ENOMEM; - } auto_sh_evt->shutdown_reason = WMI_HOST_AUTO_SHUTDOWN_REASON_TIMER_EXPIRY; @@ -255,7 +252,6 @@ QDF_STATUS wma_send_snr_request(tp_wma_handle wma_handle, if (pGetRssiReq) { pRssiBkUp = qdf_mem_malloc(sizeof(tAniGetRssiReq)); if (!pRssiBkUp) { - WMA_LOGE("Failed to alloc memory for tAniGetRssiReq"); wma_handle->pGetRssiReq = NULL; return QDF_STATUS_E_NOMEM; } @@ -304,10 +300,8 @@ QDF_STATUS wma_get_snr(tAniGetSnrReq *psnr_req) } psnr_req_bkp = qdf_mem_malloc(sizeof(tAniGetSnrReq)); - if (!psnr_req_bkp) { - WMA_LOGE("Failed to allocate memory for tAniGetSnrReq"); + if (!psnr_req_bkp) return QDF_STATUS_E_NOMEM; - } qdf_mem_set(psnr_req_bkp, sizeof(tAniGetSnrReq), 0); psnr_req_bkp->staId = psnr_req->staId; @@ -382,10 +376,8 @@ int wma_vdev_tsf_handler(void *handle, uint8_t *data, uint32_t data_len) return -EINVAL; } ptsf = qdf_mem_malloc(sizeof(*ptsf)); - if (NULL == ptsf) { - WMA_LOGE("%s: failed to allocate tsf data structure", __func__); + if (!ptsf) return -ENOMEM; - } param_buf = (WMI_VDEV_TSF_REPORT_EVENTID_param_tlvs *)data; tsf_event = param_buf->fixed_param; @@ -396,9 +388,8 @@ int wma_vdev_tsf_handler(void *handle, uint8_t *data, uint32_t data_len) ptsf->soc_timer_low = tsf_event->qtimer_low; ptsf->soc_timer_high = tsf_event->qtimer_high; - WMA_LOGD("%s: receive WMI_VDEV_TSF_REPORT_EVENTID ", __func__); - WMA_LOGD("%s: vdev_id = %u,tsf_low =%u, tsf_high = %u", __func__, - ptsf->vdev_id, ptsf->tsf_low, ptsf->tsf_high); + wma_nofl_debug("receive WMI_VDEV_TSF_REPORT_EVENTID on %d, tsf: %d %d", + ptsf->vdev_id, ptsf->tsf_low, ptsf->tsf_high); tsf_msg.type = eWNI_SME_TSF_EVENT; tsf_msg.bodyptr = ptsf; @@ -437,11 +428,8 @@ QDF_STATUS wma_capture_tsf(tp_wma_handle wma_handle, uint32_t vdev_id) int len = sizeof(*cmd); buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - if (!buf) { - WMA_LOGP("%s: failed to allocate memory for cap tsf cmd", - __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } cmd = (wmi_vdev_tsf_tstamp_action_cmd_fixed_param *) wmi_buf_data(buf); cmd->vdev_id = vdev_id; @@ -457,7 +445,6 @@ QDF_STATUS wma_capture_tsf(tp_wma_handle wma_handle, uint32_t vdev_id) ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_VDEV_TSF_TSTAMP_ACTION_CMDID); if (ret != EOK) { - WMA_LOGE("wmi_unified_cmd_send returned Error %d", status); status = QDF_STATUS_E_FAILURE; goto error; } @@ -487,11 +474,8 @@ QDF_STATUS wma_reset_tsf_gpio(tp_wma_handle wma_handle, uint32_t vdev_id) uint8_t *buf_ptr; buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - if (!buf) { - WMA_LOGP("%s: failed to allocate memory for reset tsf gpio", - __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } buf_ptr = (uint8_t *) wmi_buf_data(buf); cmd = (wmi_vdev_tsf_tstamp_action_cmd_fixed_param *) buf_ptr; @@ -510,7 +494,6 @@ QDF_STATUS wma_reset_tsf_gpio(tp_wma_handle wma_handle, uint32_t vdev_id) WMI_VDEV_TSF_TSTAMP_ACTION_CMDID); if (ret != EOK) { - WMA_LOGE("wmi_unified_cmd_send returned Error %d", status); status = QDF_STATUS_E_FAILURE; goto error; } @@ -571,11 +554,8 @@ QDF_STATUS wma_set_wisa_params(tp_wma_handle wma_handle, int ret, len = sizeof(*cmd); buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - if (!buf) { - WMA_LOGP("%s: failed to allocate memory for WISA params", - __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } cmd = (wmi_vdev_wisa_cmd_fixed_param *) wmi_buf_data(buf); cmd->wisa_mode = wisa->mode; @@ -589,7 +569,6 @@ QDF_STATUS wma_set_wisa_params(tp_wma_handle wma_handle, ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_VDEV_WISA_CMDID); if (ret != EOK) { - WMA_LOGE("wmi_unified_cmd_send returned Error %d", status); status = QDF_STATUS_E_FAILURE; goto error; } @@ -852,10 +831,9 @@ QDF_STATUS wma_get_peer_info(WMA_HANDLE handle, len = sizeof(wmi_request_stats_cmd_fixed_param); wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - if (!wmi_buf) { - WMA_LOGE("%s: wmi_buf_alloc failed", __func__); + if (!wmi_buf) return QDF_STATUS_E_NOMEM; - } + buf_ptr = (uint8_t *)wmi_buf_data(wmi_buf); cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr; @@ -871,7 +849,6 @@ QDF_STATUS wma_get_peer_info(WMA_HANDLE handle, if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len, WMI_REQUEST_STATS_CMDID)) { - WMA_LOGE("Failed to send host stats request to fw"); wmi_buf_free(wmi_buf); return QDF_STATUS_E_FAILURE; } @@ -901,10 +878,9 @@ QDF_STATUS wma_get_peer_info_ext(WMA_HANDLE handle, len = sizeof(wmi_request_peer_stats_info_cmd_fixed_param); wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - if (!wmi_buf) { - WMA_LOGE("%s: wmi_buf_alloc failed", __func__); + if (!wmi_buf) return QDF_STATUS_E_NOMEM; - } + buf_ptr = (uint8_t *)wmi_buf_data(wmi_buf); cmd = (wmi_request_peer_stats_info_cmd_fixed_param *)buf_ptr; @@ -921,7 +897,6 @@ QDF_STATUS wma_get_peer_info_ext(WMA_HANDLE handle, if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len, WMI_REQUEST_PEER_STATS_INFO_CMDID)) { - WMA_LOGE("Failed to send peer stats request to fw"); wmi_buf_free(wmi_buf); return QDF_STATUS_E_FAILURE; } @@ -976,10 +951,8 @@ QDF_STATUS wma_add_beacon_filter(WMA_HANDLE handle, iface->beacon_filter_enabled = true; wmi_buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!wmi_buf) { - WMA_LOGE("%s: wmi_buf_alloc failed", __func__); + if (!wmi_buf) return QDF_STATUS_E_NOMEM; - } buf = (u_int8_t *) wmi_buf_data(wmi_buf); @@ -1005,8 +978,6 @@ QDF_STATUS wma_add_beacon_filter(WMA_HANDLE handle, ret = wmi_unified_cmd_send(wma->wmi_handle, wmi_buf, len, WMI_ADD_BCN_FILTER_CMDID); if (ret) { - WMA_LOGE("Failed to send wmi add beacon filter = %d", - ret); wmi_buf_free(wmi_buf); return QDF_STATUS_E_FAILURE; } @@ -1037,10 +1008,9 @@ QDF_STATUS wma_remove_beacon_filter(WMA_HANDLE handle, } buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGE("%s: wmi_buf_alloc failed", __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } + cmd = (wmi_rmv_bcn_filter_cmd_fixed_param *)wmi_buf_data(buf); cmd->vdev_id = filter_params->vdev_id; @@ -1052,8 +1022,6 @@ QDF_STATUS wma_remove_beacon_filter(WMA_HANDLE handle, ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, WMI_RMV_BCN_FILTER_CMDID); if (ret) { - WMA_LOGE("Failed to send wmi remove beacon filter = %d", - ret); wmi_buf_free(buf); return QDF_STATUS_E_FAILURE; } @@ -1269,11 +1237,9 @@ int wma_nan_rsp_event_handler(void *handle, uint8_t *event_buf, nan_rsp_event_hdr->data_len, param_buf->num_data); return -EINVAL; } - nan_rsp_event = (tSirNanEvent *) qdf_mem_malloc(alloc_len); - if (NULL == nan_rsp_event) { - WMA_LOGE("%s: Memory allocation failure", __func__); + nan_rsp_event = qdf_mem_malloc(alloc_len); + if (!nan_rsp_event) return -ENOMEM; - } nan_rsp_event->event_data_len = nan_rsp_event_hdr->data_len; qdf_mem_copy(nan_rsp_event->event_data, buf_ptr + @@ -1343,10 +1309,8 @@ int wma_csa_offload_handler(void *handle, uint8_t *event, uint32_t len) } csa_offload_event = qdf_mem_malloc(sizeof(*csa_offload_event)); - if (!csa_offload_event) { - WMA_LOGE("QDF MEM Alloc Failed for csa_offload_event"); + if (!csa_offload_event) return -EINVAL; - } if (wma->interfaces[vdev_id].roaming_in_progress || wma->interfaces[vdev_id].roam_synch_in_progress) { @@ -1456,15 +1420,13 @@ int wma_oem_data_response_handler(void *handle, } oem_rsp = qdf_mem_malloc(sizeof(*oem_rsp)); - if (!oem_rsp) { - WMA_LOGE(FL("Failed to alloc oem_data_rsp")); + if (!oem_rsp) return -ENOMEM; - } + oem_rsp->rsp_len = datalen; if (oem_rsp->rsp_len) { oem_rsp->data = qdf_mem_malloc(oem_rsp->rsp_len); if (!oem_rsp->data) { - WMA_LOGE(FL("malloc failed for data")); qdf_mem_free(oem_rsp); return -ENOMEM; } @@ -2913,12 +2875,10 @@ static int wma_wake_event_piggybacked( * programmed. So do not check for cookie. */ WMA_LOGE("WOW_REASON_TIMER_INTR_RECV received, indicating key exchange did not finish. Initiate disconnect"); - del_sta_ctx = (tpDeleteStaContext) qdf_mem_malloc( - sizeof(*del_sta_ctx)); - if (!del_sta_ctx) { - WMA_LOGE("%s: mem alloc failed ", __func__); + del_sta_ctx = qdf_mem_malloc(sizeof(*del_sta_ctx)); + if (!del_sta_ctx) break; - } + del_sta_ctx->is_tdls = false; del_sta_ctx->vdev_id = event_param->fixed_param->vdev_id; del_sta_ctx->staId = peer_id; @@ -3245,9 +3205,7 @@ QDF_STATUS wma_process_tsm_stats_req(tp_wma_handle wma_handler, &packet_loss_count, tid); pTsmRspParams = qdf_mem_malloc(sizeof(*pTsmRspParams)); - if (NULL == pTsmRspParams) { - QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_ERROR, - "%s: QDF MEM Alloc Failure", __func__); + if (!pTsmRspParams) { QDF_ASSERT(0); qdf_mem_free(pTsmStatsMsg); return QDF_STATUS_E_NOMEM; @@ -3390,10 +3348,8 @@ QDF_STATUS wma_process_get_peer_info_req len = sizeof(wmi_peer_info_req_cmd_fixed_param); buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGE("%s %d: No WMI resource!", __func__, __LINE__); + if (!buf) return QDF_STATUS_E_FAILURE; - } p = (uint8_t *) wmi_buf_data(buf); qdf_mem_zero(p, len); @@ -3483,10 +3439,8 @@ QDF_STATUS wma_process_rmc_enable_ind(tp_wma_handle wma) len = sizeof(wmi_rmc_set_mode_cmd_fixed_param); buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGE("%s %d: No WMI resource!", __func__, __LINE__); + if (!buf) return QDF_STATUS_E_FAILURE; - } p = (uint8_t *) wmi_buf_data(buf); qdf_mem_zero(p, len); @@ -3535,10 +3489,8 @@ QDF_STATUS wma_process_rmc_disable_ind(tp_wma_handle wma) len = sizeof(wmi_rmc_set_mode_cmd_fixed_param); buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGE("%s %d: No WMI resource!", __func__, __LINE__); + if (!buf) return QDF_STATUS_E_FAILURE; - } p = (uint8_t *) wmi_buf_data(buf); qdf_mem_zero(p, len); @@ -3594,10 +3546,8 @@ QDF_STATUS wma_process_rmc_action_period_ind(tp_wma_handle wma) len = sizeof(wmi_rmc_set_action_period_cmd_fixed_param); buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGE("%s %d: No WMI resource!", __func__, __LINE__); + if (!buf) return QDF_STATUS_E_FAILURE; - } p = (uint8_t *) wmi_buf_data(buf); qdf_mem_zero(p, len); @@ -3648,13 +3598,8 @@ QDF_STATUS wma_process_add_periodic_tx_ptrn_ind(WMA_HANDLE handle, } params_ptr = qdf_mem_malloc(sizeof(*params_ptr)); - - if (!params_ptr) { - WMA_LOGE( - "%s: unable to allocate memory for periodic_tx_pattern", - __func__); + if (!params_ptr) return QDF_STATUS_E_NOMEM; - } if (!wma_find_vdev_by_addr(wma_handle, pAddPeriodicTxPtrnParams->mac_address.bytes, @@ -3737,11 +3682,8 @@ QDF_STATUS wma_stats_ext_req(void *wma_ptr, tpStatsExtRequest preq) params_len = sizeof(*params) + preq->request_data_len; params = qdf_mem_malloc(params_len); - - if (params == NULL) { - WMA_LOGE(FL("memory allocation failed")); + if (!params) return QDF_STATUS_E_NOMEM; - } params->vdev_id = preq->vdev_id; params->request_data_len = preq->request_data_len; @@ -3775,12 +3717,9 @@ static void wma_send_status_of_ext_wow(tp_wma_handle wma, bool status) WMA_LOGD("Posting ready to suspend indication to umac"); len = sizeof(tSirReadyToExtWoWInd); - ready_to_extwow = (tSirReadyToExtWoWInd *) qdf_mem_malloc(len); - - if (NULL == ready_to_extwow) { - WMA_LOGE("%s: Memory allocation failure", __func__); + ready_to_extwow = qdf_mem_malloc(len); + if (!ready_to_extwow) return; - } ready_to_extwow->mesgType = eWNI_SME_READY_TO_EXTWOW_IND; ready_to_extwow->mesgLen = len; @@ -3973,11 +3912,8 @@ QDF_STATUS wma_nan_req(void *wma_ptr, tpNanRequest nan_req) params_len = sizeof(*params) + nan_req->request_data_len; params = qdf_mem_malloc(params_len); - - if (params == NULL) { - WMA_LOGE(FL("memory allocation failed")); + if (!params) return QDF_STATUS_E_NOMEM; - } params->request_data_len = nan_req->request_data_len; if (params->request_data_len > 0) @@ -4287,8 +4223,7 @@ int wma_update_tdls_peer_state(WMA_HANDLE handle, if (peerStateParams->peerCap.peerChanLen) { ch_mhz = qdf_mem_malloc(sizeof(uint32_t) * peerStateParams->peerCap.peerChanLen); - if (ch_mhz == NULL) { - WMA_LOGE("%s: memory allocation failed", __func__); + if (!ch_mhz) { ret = -ENOMEM; goto end_tdls_peer_state; } @@ -4441,11 +4376,8 @@ int wma_get_apf_caps_event_handler(void *handle, u_int8_t *cmd_param_info, param_buf = (WMI_BPF_CAPABILIY_INFO_EVENTID_param_tlvs *)cmd_param_info; event = param_buf->fixed_param; apf_get_offload = qdf_mem_malloc(sizeof(*apf_get_offload)); - - if (!apf_get_offload) { - WMA_LOGP("%s: Memory allocation failed.", __func__); + if (!apf_get_offload) return -ENOMEM; - } apf_get_offload->apf_version = event->bpf_version; apf_get_offload->max_apf_filters = event->max_bpf_filters; @@ -4482,10 +4414,8 @@ QDF_STATUS wma_get_apf_capabilities(tp_wma_handle wma) len = sizeof(*cmd); wmi_buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!wmi_buf) { - WMA_LOGE("%s: wmi_buf_alloc failed", __func__); + if (!wmi_buf) return QDF_STATUS_E_NOMEM; - } buf_ptr = (u_int8_t *) wmi_buf_data(wmi_buf); cmd = (wmi_bpf_get_capability_cmd_fixed_param *) buf_ptr; @@ -4496,7 +4426,6 @@ QDF_STATUS wma_get_apf_capabilities(tp_wma_handle wma) if (wmi_unified_cmd_send(wma->wmi_handle, wmi_buf, len, WMI_BPF_GET_CAPABILITY_CMDID)) { - WMA_LOGE(FL("Failed to send APF capability command")); wmi_buf_free(wmi_buf); return QDF_STATUS_E_FAILURE; } @@ -4548,10 +4477,8 @@ QDF_STATUS wma_set_apf_instructions(tp_wma_handle wma, len += sizeof(*cmd); wmi_buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!wmi_buf) { - WMA_LOGE("%s: wmi_buf_alloc failed", __func__); + if (!wmi_buf) return QDF_STATUS_E_NOMEM; - } buf_ptr = (u_int8_t *) wmi_buf_data(wmi_buf); cmd = (wmi_bpf_set_vdev_instructions_cmd_fixed_param *) buf_ptr; @@ -4577,7 +4504,6 @@ QDF_STATUS wma_set_apf_instructions(tp_wma_handle wma, if (wmi_unified_cmd_send(wma->wmi_handle, wmi_buf, len, WMI_BPF_SET_VDEV_INSTRUCTIONS_CMDID)) { - WMA_LOGE(FL("Failed to send config apf instructions command")); wmi_buf_free(wmi_buf); return QDF_STATUS_E_FAILURE; } @@ -4753,11 +4679,8 @@ QDF_STATUS wma_set_tx_rx_aggregation_size( len = sizeof(*cmd); buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - - if (!buf) { - WMA_LOGE("%s: Failed allocate wmi buffer", __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } buf_ptr = (u_int8_t *) wmi_buf_data(buf); cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *) buf_ptr; @@ -4783,8 +4706,6 @@ QDF_STATUS wma_set_tx_rx_aggregation_size( ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID); if (ret) { - WMA_LOGE("%s: Failed to send aggregation size command", - __func__); wmi_buf_free(buf); return QDF_STATUS_E_FAILURE; } @@ -4827,11 +4748,8 @@ QDF_STATUS wma_set_tx_rx_aggregation_size_per_ac( len = sizeof(*cmd); buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - - if (!buf) { - WMA_LOGE("%s: Failed allocate wmi buffer", __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } buf_ptr = (u_int8_t *)wmi_buf_data(buf); cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)buf_ptr; @@ -4862,8 +4780,6 @@ QDF_STATUS wma_set_tx_rx_aggregation_size_per_ac( ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID); if (ret) { - WMA_LOGE("%s: Failed to send aggregation size command", - __func__); wmi_buf_free(buf); return QDF_STATUS_E_FAILURE; } @@ -4911,11 +4827,8 @@ QDF_STATUS wma_set_sw_retry_threshold( len = sizeof(*cmd); buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - - if (!buf) { - WMA_LOGE("%s: Failed allocate wmi buffer", __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } buf_ptr = (u_int8_t *)wmi_buf_data(buf); cmd = @@ -4938,8 +4851,6 @@ QDF_STATUS wma_set_sw_retry_threshold( ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_VDEV_SET_CUSTOM_SW_RETRY_TH_CMDID); if (ret) { - WMA_LOGE("%s: Failed to send retry threshold command", - __func__); wmi_buf_free(buf); return QDF_STATUS_E_FAILURE; } @@ -4981,11 +4892,8 @@ QDF_STATUS wma_p2p_lo_start(struct sir_p2p_lo_start *params) probe_resp_len_aligned; buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGP("%s: failed to allocate memory for p2p lo start", - __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf); buf_ptr = (uint8_t *) wmi_buf_data(buf); @@ -5022,12 +4930,11 @@ QDF_STATUS wma_p2p_lo_start(struct sir_p2p_lo_start *params) ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, WMI_P2P_LISTEN_OFFLOAD_START_CMDID); - if (ret) { - WMA_LOGE("Failed to send p2p lo start: %d", ret); + if (ret) wmi_buf_free(buf); - } + else + WMA_LOGI("%s: Successfully sent WMI_P2P_LO_START", __func__); - WMA_LOGI("%s: Successfully sent WMI_P2P_LO_START", __func__); wma->interfaces[params->vdev_id].p2p_lo_in_progress = true; return ret; @@ -5056,11 +4963,9 @@ QDF_STATUS wma_p2p_lo_stop(u_int32_t vdev_id) len = sizeof(*cmd); buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGP("%s: failed to allocate memory for p2p lo stop", - __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } + cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf); WMITLV_SET_HDR(&cmd->tlv_header, @@ -5075,12 +4980,10 @@ QDF_STATUS wma_p2p_lo_stop(u_int32_t vdev_id) ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID); - if (ret) { - WMA_LOGE("Failed to send p2p lo stop: %d", ret); + if (ret) wmi_buf_free(buf); - } - - WMA_LOGI("%s: Successfully sent WMI_P2P_LO_STOP", __func__); + else + WMA_LOGI("%s: Successfully sent WMI_P2P_LO_STOP", __func__); wma->interfaces[vdev_id].p2p_lo_in_progress = false; return ret; @@ -5130,10 +5033,9 @@ int wma_p2p_lo_event_handler(void *handle, uint8_t *event_buf, return -EINVAL; } event = qdf_mem_malloc(sizeof(*event)); - if (event == NULL) { - WMA_LOGE("Event allocation failed"); + if (!event) return -ENOMEM; - } + event->vdev_id = fix_param->vdev_id; event->reason_code = fix_param->reason; @@ -5256,10 +5158,9 @@ QDF_STATUS wma_enable_disable_caevent_ind(tp_wma_handle wma, uint8_t val) len = sizeof(*cmd); wmi_buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!wmi_buf) { - WMA_LOGE(FL("wmi_buf_alloc failed")); + if (!wmi_buf) return QDF_STATUS_E_NOMEM; - } + buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf); cmd = (WMI_CHAN_AVOID_RPT_ALLOW_CMD_fixed_param *) buf_ptr; WMITLV_SET_HDR(&cmd->tlv_header, @@ -5269,7 +5170,6 @@ QDF_STATUS wma_enable_disable_caevent_ind(tp_wma_handle wma, uint8_t val) cmd->rpt_allow = val; if (wmi_unified_cmd_send(wma->wmi_handle, wmi_buf, len, WMI_CHAN_AVOID_RPT_ALLOW_CMDID)) { - WMA_LOGE(FL("Failed to send enable/disable CA event command")); wmi_buf_free(wmi_buf); return QDF_STATUS_E_FAILURE; } @@ -5303,10 +5203,8 @@ static int wma_sar_event_handler(void *handle, uint8_t *evt_buf, uint32_t len) } event = qdf_mem_malloc(sizeof(*event)); - if (!event) { - WMA_LOGE(FL("failed to malloc sar_limit_event")); + if (!event) return QDF_STATUS_E_NOMEM; - } status = wmi_unified_extract_sar_limit_event(wmi_handle, evt_buf, event); @@ -5546,11 +5444,9 @@ int wma_unified_power_debug_stats_event_handler(void *handle, (sizeof(uint32_t) * param_buf->num_debug_register); power_stats_len = stats_registers_len + sizeof(*power_stats_results); power_stats_results = qdf_mem_malloc(power_stats_len); - if (!power_stats_results) { - WMA_LOGD("%s: could not allocate mem for power stats results", - __func__); + if (!power_stats_results) return -ENOMEM; - } + WMA_LOGD("Cumulative sleep time %d cumulative total on time %d deep sleep enter counter %d last deep sleep enter tstamp ts %d debug registers fmt %d num debug register %d", param_buf->cumulative_sleep_time_ms, param_buf->cumulative_total_on_time_ms, @@ -5643,12 +5539,10 @@ int wma_chan_info_event_handler(void *handle, uint8_t *event_buf, return -EINVAL; } event = param_buf->fixed_param; - channel_status = - qdf_mem_malloc(sizeof(*channel_status)); - if (!channel_status) { - WMA_LOGE(FL("Mem alloc fail")); + channel_status = qdf_mem_malloc(sizeof(*channel_status)); + if (!channel_status) return -ENOMEM; - } + WMA_LOGD(FL("freq=%d nf=%d rxcnt=%u cyccnt=%u tx_r=%d tx_t=%d"), event->freq, event->noise_floor, @@ -5723,10 +5617,8 @@ int wma_rx_aggr_failure_event_handler(void *handle, u_int8_t *event_buf, (rx_aggr_failure_info->num_failure_info)* sizeof(rx_aggr_hole_event->hole_info_array[0]); rx_aggr_hole_event = qdf_mem_malloc(alloc_len); - if (NULL == rx_aggr_hole_event) { - WMA_LOGE("%s: Memory allocation failure", __func__); + if (!rx_aggr_hole_event) return -ENOMEM; - } rx_aggr_hole_event->hole_cnt = rx_aggr_failure_info->num_failure_info; if (rx_aggr_hole_event->hole_cnt > param_buf->num_failure_info) { @@ -5863,10 +5755,8 @@ int wma_vdev_obss_detection_info_handler(void *handle, uint8_t *event, } obss_detection = qdf_mem_malloc(sizeof(*obss_detection)); - if (!obss_detection) { - WMA_LOGE("%s: Failed to malloc", __func__); + if (!obss_detection) return -ENOMEM; - } status = wmi_unified_extract_obss_detection_info(wma->wmi_handle, event, obss_detection); @@ -5903,10 +5793,8 @@ int wma_vdev_bss_color_collision_info_handler(void *handle, } obss_color_info = qdf_mem_malloc(sizeof(*obss_color_info)); - if (!obss_color_info) { - WMA_LOGE("%s: Failed to malloc", __func__); + if (!obss_color_info) return -ENOMEM; - } status = wmi_unified_extract_obss_color_collision_info(wma->wmi_handle, event, diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c index 20b159218d3f..95e013a477c1 100644 --- a/core/wma/src/wma_main.c +++ b/core/wma/src/wma_main.c @@ -562,10 +562,8 @@ int wma_cli_set2_command(int vdev_id, int param_id, int sval1, wma_cli_set_cmd_t *iwcmd; iwcmd = qdf_mem_malloc(sizeof(*iwcmd)); - if (!iwcmd) { - WMA_LOGE("%s: Failed alloc memory for iwcmd", __func__); + if (!iwcmd) return -ENOMEM; - } qdf_mem_zero(iwcmd, sizeof(*iwcmd)); iwcmd->param_value = sval1; @@ -624,10 +622,9 @@ QDF_STATUS wma_form_unit_test_cmd_and_send(uint32_t vdev_id, return QDF_STATUS_E_FAILURE; } unit_test_args = qdf_mem_malloc(sizeof(*unit_test_args)); - if (NULL == unit_test_args) { - WMA_LOGE(FL("qdf_mem_malloc failed for unit_test_args")); + if (!unit_test_args) return QDF_STATUS_E_NOMEM; - } + unit_test_args->vdev_id = vdev_id; unit_test_args->module_id = module_id; unit_test_args->num_args = arg_count; @@ -1722,7 +1719,6 @@ static int wma_process_fw_event_mc_thread_ctx(void *ctx, void *ev) params_buf = qdf_mem_malloc(sizeof(wma_process_fw_event_params)); if (!params_buf) { - WMA_LOGE("%s: Failed alloc memory for params_buf", __func__); qdf_nbuf_free(ev); return -ENOMEM; } @@ -3220,7 +3216,6 @@ QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc, */ params = qdf_mem_malloc(sizeof(*params) + sizeof(struct wmi_rx_ops)); if (!params) { - WMA_LOGE("%s: failed to allocate attach params", __func__); qdf_status = QDF_STATUS_E_NOMEM; goto err_wma_handle; } @@ -3311,7 +3306,6 @@ QDF_STATUS wma_open(struct wlan_objmgr_psoc *psoc, wma_handle->interfaces = qdf_mem_malloc(sizeof(struct wma_txrx_node) * wma_handle->max_bssid); if (!wma_handle->interfaces) { - WMA_LOGE("%s: failed to allocate interface table", __func__); qdf_status = QDF_STATUS_E_NOMEM; goto err_scn_context; } @@ -3892,7 +3886,6 @@ static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle, hw_mode_resp = qdf_mem_malloc(sizeof(*hw_mode_resp)); if (!hw_mode_resp) { - WMA_LOGE("%s: Memory allocation failed", __func__); /* Since this memory allocation itself failed, we cannot * send fail response back to LIM here */ @@ -4108,10 +4101,8 @@ static int wma_pdev_hw_mode_transition_evt_handler(void *handle, } hw_mode_trans_ind = qdf_mem_malloc(sizeof(*hw_mode_trans_ind)); - if (!hw_mode_trans_ind) { - WMA_LOGE("%s: Memory allocation failed", __func__); + if (!hw_mode_trans_ind) return QDF_STATUS_E_NOMEM; - } wmi_event = param_buf->fixed_param; vdev_mac_entry = @@ -4164,13 +4155,11 @@ static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle, } wma_release_wakelock(&wma->wmi_cmd_rsp_wake_lock); dual_mac_cfg_resp = qdf_mem_malloc(sizeof(*dual_mac_cfg_resp)); - if (!dual_mac_cfg_resp) { - WMA_LOGE("%s: Memory allocation failed", __func__); + if (!dual_mac_cfg_resp) /* Since the mem alloc failed, we cannot send resp to LIM. * So, returning from here. */ return QDF_STATUS_E_NULL_VALUE; - } param_buf = (WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID_param_tlvs *) event; @@ -5794,13 +5783,13 @@ int wma_rx_service_ready_event(void *handle, uint8_t *cmd_param_info, wma_handle->num_dbs_hw_modes = ev->num_dbs_hw_modes; ev_wlan_dbs_hw_mode_list = param_buf->wlan_dbs_hw_mode_list; + + /* Continuing with the rest of the processing, + * even if memory allocation fails + */ wma_handle->hw_mode.hw_mode_list = qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) * wma_handle->num_dbs_hw_modes); - if (!wma_handle->hw_mode.hw_mode_list) { - WMA_LOGE("%s: Memory allocation failed for DBS", __func__); - /* Continuing with the rest of the processing */ - } if (wma_handle->hw_mode.hw_mode_list) qdf_mem_copy(wma_handle->hw_mode.hw_mode_list, @@ -6477,10 +6466,8 @@ static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle, wma_handle->hw_mode.hw_mode_list = qdf_mem_malloc(sizeof(*wma_handle->hw_mode.hw_mode_list) * num_hw_modes); - if (!wma_handle->hw_mode.hw_mode_list) { - WMA_LOGE("%s: Memory allocation failed for DBS", __func__); + if (!wma_handle->hw_mode.hw_mode_list) return QDF_STATUS_E_FAILURE; - } WMA_LOGD("%s: Updated HW mode list: Num modes:%d", __func__, num_hw_modes); @@ -7327,10 +7314,8 @@ static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle, len = sizeof(*cmd); buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - if (!buf) { - WMA_LOGE("wmi_buf_alloc failed"); + if (!buf) return QDF_STATUS_E_NOMEM; - } cmd = (WMI_WOW_HOSTWAKEUP_GPIO_CMD_FIXED_PARAM *)wmi_buf_data(buf); qdf_mem_zero(cmd, len); @@ -7348,7 +7333,6 @@ static QDF_STATUS wma_send_wow_pulse_cmd(tp_wma_handle wma_handle, if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID)) { - WMA_LOGE("Failed to send send wow pulse"); wmi_buf_free(buf); status = QDF_STATUS_E_FAILURE; } @@ -7393,10 +7377,8 @@ static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle) len = sizeof(*cmd); buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - if (!buf) { - WMA_LOGE("%s: Failed allocate wmi buffer", __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } buf_ptr = (u_int8_t *) wmi_buf_data(buf); cmd = (wmi_pdev_get_chip_power_stats_cmd_fixed_param *) buf_ptr; @@ -7412,8 +7394,6 @@ static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle) ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_PDEV_GET_CHIP_POWER_STATS_CMDID); if (ret) { - WMA_LOGE("%s: Failed to send power debug stats request", - __func__); wmi_buf_free(buf); return QDF_STATUS_E_FAILURE; } @@ -7561,11 +7541,9 @@ QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle, } len = sizeof(*cmd); buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - - if (!buf) { - WMA_LOGE(FL("Failed allocate wmi buffer")); + if (!buf) return QDF_STATUS_E_NOMEM; - } + cmd = (wmi_pdev_set_reorder_timeout_val_cmd_fixed_param *) wmi_buf_data(buf); @@ -7583,7 +7561,6 @@ QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle, ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID); if (ret) { - WMA_LOGE(FL("Failed to send aggregation timeout")); wmi_buf_free(buf); return QDF_STATUS_E_FAILURE; } @@ -7612,11 +7589,8 @@ QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle, len = sizeof(*cmd); buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - - if (!buf) { - WMA_LOGE(FL("Failed allocate wmi buffer")); + if (!buf) return QDF_STATUS_E_NOMEM; - } buf_ptr = (u_int8_t *) wmi_buf_data(buf); cmd = (wmi_peer_set_rx_blocksize_cmd_fixed_param *) buf_ptr; @@ -7636,7 +7610,6 @@ QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle, ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_PEER_SET_RX_BLOCKSIZE_CMDID); if (ret) { - WMA_LOGE(FL("Failed to send aggregation size command")); wmi_buf_free(buf); return QDF_STATUS_E_FAILURE; } @@ -7658,10 +7631,8 @@ QDF_STATUS wma_get_chain_rssi(tp_wma_handle wma_handle, } wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len); - if (!wmi_buf) { - WMA_LOGE(FL("wmi_buf_alloc failed")); + if (!wmi_buf) return QDF_STATUS_E_NOMEM; - } buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf); @@ -7676,7 +7647,6 @@ QDF_STATUS wma_get_chain_rssi(tp_wma_handle wma_handle, if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len, WMI_PDEV_DIV_GET_RSSI_ANTID_CMDID)) { - WMA_LOGE(FL("failed to send get chain rssi command")); wmi_buf_free(wmi_buf); return QDF_STATUS_E_FAILURE; } @@ -7699,10 +7669,8 @@ static QDF_STATUS wma_roam_scan_send_hlp(tp_wma_handle wma_handle, QDF_STATUS status; params = qdf_mem_malloc(sizeof(*params)); - if (!params) { - WMA_LOGE("%s : Memory allocation failed", __func__); + if (!params) return QDF_STATUS_E_NOMEM; - } params->vdev_id = req->vdev_id; params->hlp_ie_len = req->hlp_ie_len; @@ -8763,10 +8731,9 @@ QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle, return QDF_STATUS_SUCCESS; fail: param = qdf_mem_malloc(sizeof(*param)); - if (!param) { - WMA_LOGE("%s: Memory allocation failed", __func__); + if (!param) return QDF_STATUS_E_NULL_VALUE; - } + param->status = SET_HW_MODE_STATUS_ECANCELED; param->cfgd_hw_mode_index = 0; param->num_vdev_mac_entries = 0; @@ -8856,7 +8823,6 @@ QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle, buf = wmi_buf_alloc(wma_handle->wmi_handle, len); if (!buf) { - WMA_LOGE("%s: wmi_buf_alloc failed", __func__); status = QDF_STATUS_E_NOMEM; goto resp; } @@ -8878,8 +8844,6 @@ QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle, if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, WMI_PDEV_SET_ANTENNA_MODE_CMDID)) { - WMA_LOGE("%s: Failed to send WMI_PDEV_SET_ANTENNA_MODE_CMDID", - __func__); wmi_buf_free(buf); status = QDF_STATUS_E_FAILURE; goto resp; @@ -8888,10 +8852,9 @@ QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle, resp: param = qdf_mem_malloc(sizeof(*param)); - if (!param) { - WMA_LOGE("%s: Memory allocation failed", __func__); + if (!param) return QDF_STATUS_E_NOMEM; - } + param->status = (status) ? SET_ANTENNA_MODE_STATUS_ECANCELED : SET_ANTENNA_MODE_STATUS_OK; @@ -8931,10 +8894,8 @@ int wma_lro_init(struct cdp_lro_hash_config *lro_config) struct cdp_lro_hash_config *iwcmd; iwcmd = qdf_mem_malloc(sizeof(*iwcmd)); - if (!iwcmd) { - WMA_LOGE("memory allocation for WMA_LRO_CONFIG_CMD failed!"); + if (!iwcmd) return -ENOMEM; - } *iwcmd = *lro_config; diff --git a/core/wma/src/wma_mgmt.c b/core/wma/src/wma_mgmt.c index f4c70f039981..96bd2015e225 100644 --- a/core/wma/src/wma_mgmt.c +++ b/core/wma/src/wma_mgmt.c @@ -4117,8 +4117,6 @@ static int wma_mgmt_rx_process(void *handle, uint8_t *data, RESERVE_BYTES, 4), 0, 4, false); if (!wbuf) { - WMA_LOGE("%s: Failed to allocate wbuf for mgmt rx len(%u)", - __func__, mgmt_rx_params->buf_len); qdf_mem_free(mgmt_rx_params); return -ENOMEM; } diff --git a/core/wma/src/wma_ocb.c b/core/wma/src/wma_ocb.c index 8889cac4b1ca..64da7c201d69 100644 --- a/core/wma/src/wma_ocb.c +++ b/core/wma/src/wma_ocb.c @@ -253,10 +253,8 @@ int wma_ocb_set_config(tp_wma_handle wma_handle, struct sir_ocb_config *config) config->dcc_ndl_active_state_list_len; tconfig.dcc_ndl_active_state_list = config->dcc_ndl_active_state_list; ch_mhz = qdf_mem_malloc(sizeof(uint32_t)*config->channel_count); - if (ch_mhz == NULL) { - WMA_LOGE(FL("Memory allocation failed")); + if (!ch_mhz) return -ENOMEM; - } for (i = 0; i < config->channel_count; i++) ch_mhz[i] = wma_ocb_freq_to_mode(config->channels[i].chan_freq); @@ -435,8 +433,9 @@ static int wma_ocb_get_tsf_timer_resp_event_handler(void *handle, /* Allocate and populate the response */ response = qdf_mem_malloc(sizeof(*response)); - if (response == NULL) + if (!response) return -ENOMEM; + response->vdev_id = fix_param->vdev_id; response->timer_high = fix_param->tsf_timer_high; response->timer_low = fix_param->tsf_timer_low; @@ -517,7 +516,7 @@ static int wma_dcc_get_stats_resp_event_handler(void *handle, } response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels * sizeof(wmi_dcc_ndl_stats_per_channel)); - if (response == NULL) + if (!response) return -ENOMEM; response->vdev_id = fix_param->vdev_id; @@ -616,10 +615,9 @@ static int wma_dcc_update_ndl_resp_event_handler(void *handle, fix_param = param_tlvs->fixed_param; /* Allocate and populate the response */ resp = qdf_mem_malloc(sizeof(*resp)); - if (!resp) { - WMA_LOGE(FL("Error allocating memory for the response.")); + if (!resp) return -ENOMEM; - } + resp->vdev_id = fix_param->vdev_id; resp->status = fix_param->status; @@ -667,8 +665,9 @@ static int wma_dcc_stats_event_handler(void *handle, uint8_t *event_buf, } response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels * sizeof(wmi_dcc_ndl_stats_per_channel)); - if (response == NULL) + if (!response) return -ENOMEM; + response->vdev_id = fix_param->vdev_id; response->num_channels = fix_param->num_channels; response->channel_stats_array_len = diff --git a/core/wma/src/wma_power.c b/core/wma/src/wma_power.c index 5cde71783b7f..c23151b8052a 100644 --- a/core/wma/src/wma_power.c +++ b/core/wma/src/wma_power.c @@ -70,10 +70,9 @@ wma_unified_modem_power_state(wmi_unified_t wmi_handle, uint32_t param_value) uint16_t len = sizeof(*cmd); buf = wmi_buf_alloc(wmi_handle, len); - if (!buf) { - WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + if (!buf) return -ENOMEM; - } + cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf); WMITLV_SET_HDR(&cmd->tlv_header, WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param, @@ -84,10 +83,9 @@ wma_unified_modem_power_state(wmi_unified_t wmi_handle, uint32_t param_value) param_value); ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_MODEM_POWER_STATE_CMDID); - if (ret != EOK) { - WMA_LOGE("Failed to send notify cmd ret = %d", ret); + if (ret != EOK) wmi_buf_free(buf); - } + return ret; } @@ -1427,13 +1425,10 @@ void wma_update_noa(struct beacon_info *beacon, void wma_update_probe_resp_noa(tp_wma_handle wma_handle, struct p2p_sub_element_noa *noa_ie) { - tSirP2PNoaAttr *noa_attr = - (tSirP2PNoaAttr *) qdf_mem_malloc(sizeof(tSirP2PNoaAttr)); + tSirP2PNoaAttr *noa_attr = qdf_mem_malloc(sizeof(tSirP2PNoaAttr)); WMA_LOGD("Received update NoA event"); - if (!noa_attr) { - WMA_LOGE("Failed to allocate memory for tSirP2PNoaAttr"); + if (!noa_attr) return; - } qdf_mem_zero(noa_attr, sizeof(tSirP2PNoaAttr)); diff --git a/core/wma/src/wma_scan_roam.c b/core/wma/src/wma_scan_roam.c index 57dda00b2832..cb82f759d6c2 100644 --- a/core/wma/src/wma_scan_roam.c +++ b/core/wma/src/wma_scan_roam.c @@ -125,10 +125,9 @@ QDF_STATUS wma_update_channel_list(WMA_HANDLE handle, scan_ch_param.chan_info = qdf_mem_malloc(sizeof(wmi_channel) * chan_list->numChan); - if (NULL == scan_ch_param.chan_info) { - WMA_LOGE("%s: Failed to allocate channel info", __func__); + if (!scan_ch_param.chan_info) return QDF_STATUS_E_NOMEM; - } + qdf_mem_zero(scan_ch_param.chan_info, sizeof(wmi_channel) * chan_list->numChan); WMA_LOGD("no of channels = %d", chan_list->numChan); @@ -213,10 +212,9 @@ QDF_STATUS wma_roam_scan_mawc_params(tp_wma_handle wma_handle, return QDF_STATUS_E_INVAL; } params = qdf_mem_malloc(sizeof(*params)); - if (!params) { - WMA_LOGE("No memory allocated for MAWC roam params"); + if (!params) return QDF_STATUS_E_NOMEM; - } + params->vdev_id = roam_req->sessionId; params->enable = roam_req->mawc_roam_params.mawc_enabled && roam_req->mawc_roam_params.mawc_roam_enabled; @@ -310,10 +308,9 @@ QDF_STATUS wma_roam_scan_offload_mode(tp_wma_handle wma_handle, struct roam_offload_scan_params *params = qdf_mem_malloc(sizeof(*params)); - if (!params) { - WMA_LOGE("%s: Failed to allocate scan params", __func__); + if (!params) return QDF_STATUS_E_NOMEM; - } + #ifdef WLAN_FEATURE_ROAM_OFFLOAD params->auth_mode = WMI_AUTH_NONE; if (roam_req) @@ -602,10 +599,8 @@ QDF_STATUS wma_roam_scan_offload_chan_list(tp_wma_handle wma_handle, return QDF_STATUS_E_EMPTY; } chan_list_mhz = qdf_mem_malloc(chan_count * sizeof(*chan_list_mhz)); - if (chan_list_mhz == NULL) { - WMA_LOGE("%s : Memory allocation failed", __func__); + if (!chan_list_mhz) return QDF_STATUS_E_NOMEM; - } for (i = 0; ((i < chan_count) && (i < SIR_ROAM_MAX_CHANNELS)); i++) { @@ -857,10 +852,9 @@ void wma_process_set_pdev_ht_ie_req(tp_wma_handle wma, len += ie_len_pad; buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + if (!buf) return; - } + cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *) wmi_buf_data(buf); WMITLV_SET_HDR(&cmd->tlv_header, WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param, @@ -881,10 +875,8 @@ void wma_process_set_pdev_ht_ie_req(tp_wma_handle wma, } ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, WMI_PDEV_SET_HT_CAP_IE_CMDID); - if (ret != EOK) { - WMA_LOGE("Failed to send set param command ret = %d", ret); + if (ret != EOK) wmi_buf_free(buf); - } } /** @@ -912,10 +904,9 @@ void wma_process_set_pdev_vht_ie_req(tp_wma_handle wma, len += ie_len_pad; buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + if (!buf) return; - } + cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *) wmi_buf_data(buf); WMITLV_SET_HDR(&cmd->tlv_header, WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param, @@ -936,10 +927,8 @@ void wma_process_set_pdev_vht_ie_req(tp_wma_handle wma, } ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, WMI_PDEV_SET_VHT_CAP_IE_CMDID); - if (ret != EOK) { - WMA_LOGE("Failed to send set param command ret = %d", ret); + if (ret != EOK) wmi_buf_free(buf); - } } /** @@ -1173,10 +1162,8 @@ static QDF_STATUS wma_roam_scan_filter(tp_wma_handle wma_handle, struct lca_disallow_config_params *lca_config_params; params = qdf_mem_malloc(sizeof(struct roam_scan_filter_params)); - if (params == NULL) { - WMA_LOGE("%s : Memory allocation failed", __func__); + if (!params) return QDF_STATUS_E_NOMEM; - } roam_params = &roam_req->roam_params; lca_config_params = &roam_req->lca_config_params; @@ -1346,10 +1333,8 @@ static QDF_STATUS wma_roam_scan_btm_offload(tp_wma_handle wma_handle, QDF_STATUS status; params = qdf_mem_malloc(sizeof(struct wmi_btm_config)); - if (!params) { - WMA_LOGE("Memory alloc failed for btm params"); + if (!params) return QDF_STATUS_E_FAILURE; - } params->vdev_id = roam_req->sessionId; params->btm_offload_config = roam_req->btm_offload_config; @@ -1669,8 +1654,6 @@ QDF_STATUS wma_process_roaming_config(tp_wma_handle wma_handle, scan_offload_rsp = qdf_mem_malloc(sizeof(*scan_offload_rsp)); if (!scan_offload_rsp) { - WMA_LOGE("%s: Alloc failed for scan_offload_rsp", - __func__); qdf_mem_free(roam_req); return QDF_STATUS_E_NOMEM; } @@ -2224,10 +2207,9 @@ static void wma_roam_update_vdev(tp_wma_handle wma, set_link_params = qdf_mem_malloc(sizeof(*set_link_params)); add_sta_params = qdf_mem_malloc(sizeof(*add_sta_params)); if (!del_bss_params || !del_sta_params || - !set_link_params || !add_sta_params) { - WMA_LOGE("%s: failed to allocate memory", __func__); + !set_link_params || !add_sta_params) return; - } + qdf_mem_zero(del_bss_params, sizeof(*del_bss_params)); qdf_mem_zero(del_sta_params, sizeof(*del_sta_params)); qdf_mem_zero(set_link_params, sizeof(*set_link_params)); @@ -2428,11 +2410,8 @@ int wma_roam_synch_event_handler(void *handle, uint8_t *event, wma->interfaces[synch_event->vdev_id].roam_synch_in_progress = true; - roam_synch_ind_ptr = - (roam_offload_synch_ind *)qdf_mem_malloc(roam_synch_data_len); + roam_synch_ind_ptr = qdf_mem_malloc(roam_synch_data_len); if (!roam_synch_ind_ptr) { - WMA_LOGE("%s: failed to allocate memory for roam_synch_event", - __func__); QDF_ASSERT(roam_synch_ind_ptr != NULL); status = -ENOMEM; goto cleanup_label; @@ -2452,8 +2431,7 @@ int wma_roam_synch_event_handler(void *handle, uint8_t *event, goto cleanup_label; } bss_desc_ptr = qdf_mem_malloc(sizeof(tSirBssDescription) + ie_len); - if (NULL == bss_desc_ptr) { - WMA_LOGE("LFR3: mem alloc failed!"); + if (!bss_desc_ptr) { QDF_ASSERT(bss_desc_ptr != NULL); status = -ENOMEM; goto cleanup_label; @@ -2596,7 +2574,6 @@ int wma_roam_synch_frame_event_handler(void *handle, uint8_t *event, qdf_mem_malloc(iface->roam_synch_frame_ind. bcn_probe_rsp_len); if (!iface->roam_synch_frame_ind.bcn_probe_rsp) { - WMA_LOGE("failed to allocate memory for bcn_probe_rsp"); QDF_ASSERT(iface->roam_synch_frame_ind. bcn_probe_rsp != NULL); status = -ENOMEM; @@ -2619,7 +2596,6 @@ int wma_roam_synch_frame_event_handler(void *handle, uint8_t *event, qdf_mem_malloc(iface->roam_synch_frame_ind. reassoc_req_len); if (!iface->roam_synch_frame_ind.reassoc_req) { - WMA_LOGE("failed to allocate memory for reassoc_req"); QDF_ASSERT(iface->roam_synch_frame_ind. reassoc_req != NULL); status = -ENOMEM; @@ -2642,7 +2618,6 @@ int wma_roam_synch_frame_event_handler(void *handle, uint8_t *event, qdf_mem_malloc(iface->roam_synch_frame_ind. reassoc_rsp_len); if (!iface->roam_synch_frame_ind.reassoc_rsp) { - WMA_LOGE("failed to allocate memory for reassoc_req"); QDF_ASSERT(iface->roam_synch_frame_ind. reassoc_rsp != NULL); status = -ENOMEM; @@ -2945,11 +2920,9 @@ static void wma_roam_ho_fail_handler(tp_wma_handle wma, uint32_t vdev_id) QDF_STATUS qdf_status; ho_failure_ind = qdf_mem_malloc(sizeof(tSirSmeHOFailureInd)); - - if (NULL == ho_failure_ind) { - WMA_LOGE("%s: Memory allocation failure", __func__); + if (!ho_failure_ind) return; - } + ho_failure_ind->sessionId = vdev_id; sme_msg.type = eWNI_SME_HO_FAIL_IND; sme_msg.bodyptr = ho_failure_ind; @@ -3473,10 +3446,9 @@ int wma_extscan_start_stop_event_handler(void *handle, } event = param_buf->fixed_param; extscan_ind = qdf_mem_malloc(sizeof(*extscan_ind)); - if (!extscan_ind) { - WMA_LOGE("%s: extscan memory allocation failed", __func__); + if (!extscan_ind) return -ENOMEM; - } + switch (event->command) { case WMI_EXTSCAN_START_CMDID: event_type = eSIR_EXTSCAN_START_RSP; @@ -3572,11 +3544,8 @@ int wma_extscan_operations_event_handler(void *handle, } oprn_event = param_buf->fixed_param; oprn_ind = qdf_mem_malloc(sizeof(*oprn_ind)); - if (!oprn_ind) { - WMA_LOGE("%s: extscan memory allocation failed", __func__); - qdf_mem_free(oprn_ind); + if (!oprn_ind) return -ENOMEM; - } oprn_ind->requestId = oprn_event->request_id; @@ -3688,10 +3657,9 @@ int wma_extscan_table_usage_event_handler(void *handle, } event = param_buf->fixed_param; tbl_usg_ind = qdf_mem_malloc(sizeof(*tbl_usg_ind)); - if (!tbl_usg_ind) { - WMA_LOGE("%s: table usage allocation failed", __func__); + if (!tbl_usg_ind) return -ENOMEM; - } + tbl_usg_ind->requestId = event->request_id; tbl_usg_ind->numResultsAvailable = event->entries_in_use; pMac->sme.ext_scan_ind_cb(pMac->hdd_handle, @@ -3749,11 +3717,9 @@ int wma_extscan_capabilities_event_handler(void *handle, return -EINVAL; } dest_capab = qdf_mem_malloc(sizeof(*dest_capab)); - if (!dest_capab) { - WMA_LOGE("%s: Allocation failed for capabilities buffer", - __func__); + if (!dest_capab) return -ENOMEM; - } + dest_capab->requestId = event->request_id; dest_capab->max_scan_buckets = src_cache->max_buckets; dest_capab->max_scan_cache_size = src_cache->scan_cache_entry_size; @@ -3875,10 +3841,9 @@ int wma_extscan_hotlist_match_event_handler(void *handle, dest_hotlist = qdf_mem_malloc(sizeof(*dest_hotlist) + sizeof(*dest_ap) * numap); - if (!dest_hotlist) { - WMA_LOGE("%s: Allocation failed for hotlist buffer", __func__); + if (!dest_hotlist) return -ENOMEM; - } + dest_ap = &dest_hotlist->ap[0]; dest_hotlist->numOfAps = event->total_entries; dest_hotlist->requestId = event->config_request_id; @@ -4064,10 +4029,8 @@ static int wma_group_num_bss_to_scan_id(const u_int8_t *cmd_param_info, t_scan_id_grp->num_results); t_scan_id_grp->ap = qdf_mem_malloc(t_scan_id_grp->num_results * sizeof(*ap)); - if (!t_scan_id_grp->ap) { - WMA_LOGD("%s: qdf_mem_malloc failed", __func__); + if (!t_scan_id_grp->ap) return -ENOMEM; - } ap = &t_scan_id_grp->ap[0]; for (j = 0; j < QDF_MIN(t_scan_id_grp->num_results, @@ -4206,10 +4169,9 @@ int wma_extscan_cached_results_event_handler(void *handle, moredata = 0; dest_cachelist = qdf_mem_malloc(sizeof(*dest_cachelist)); - if (!dest_cachelist) { - WMA_LOGE("%s: qdf_mem_malloc failed", __func__); + if (!dest_cachelist) return -ENOMEM; - } + qdf_mem_zero(dest_cachelist, sizeof(*dest_cachelist)); dest_cachelist->request_id = event->request_id; dest_cachelist->more_data = moredata; @@ -4221,7 +4183,6 @@ int wma_extscan_cached_results_event_handler(void *handle, buf_len = sizeof(*dest_result) * scan_ids_cnt; dest_cachelist->result = qdf_mem_malloc(buf_len); if (!dest_cachelist->result) { - WMA_LOGE("%s: Allocation failed for scanid grouping", __func__); qdf_mem_free(dest_cachelist); return -ENOMEM; } @@ -4362,10 +4323,9 @@ int wma_extscan_change_results_event_handler(void *handle, dest_chglist = qdf_mem_malloc(sizeof(*dest_chglist) + sizeof(*dest_ap) * numap + sizeof(int32_t) * rssi_num); - if (!dest_chglist) { - WMA_LOGE("%s: Allocation failed for change monitor", __func__); + if (!dest_chglist) return -ENOMEM; - } + dest_ap = &dest_chglist->ap[0]; for (i = 0; i < numap; i++) { dest_ap->channel = src_chglist->channel; @@ -4478,10 +4438,9 @@ int wma_passpoint_match_event_handler(void *handle, dest_match = qdf_mem_malloc(sizeof(*dest_match) + buf_len); - if (!dest_match) { - WMA_LOGE("%s: qdf_mem_malloc failed", __func__); + if (!dest_match) return -EINVAL; - } + dest_ap = &dest_match->ap; dest_match->request_id = 0; dest_match->id = event->id; @@ -4543,10 +4502,8 @@ QDF_STATUS wma_start_extscan(tp_wma_handle wma, } params = qdf_mem_malloc(sizeof(struct wifi_scan_cmd_req_params)); - if (params == NULL) { - WMA_LOGE("%s : Memory allocation failed", __func__); + if (!params) return QDF_STATUS_E_NOMEM; - } params->base_period = pstart->basePeriod; params->max_ap_per_scan = pstart->maxAPperScan; @@ -4818,10 +4775,8 @@ QDF_STATUS wma_set_epno_network_list(tp_wma_handle wma, params_len = sizeof(*params) + (req->num_networks * sizeof(struct wifi_epno_network_params)); params = qdf_mem_malloc(params_len); - if (params == NULL) { - WMA_LOGE(FL("memory allocation failed")); + if (!params) return QDF_STATUS_E_NOMEM; - } params->request_id = req->request_id; params->vdev_id = req->session_id; @@ -4895,10 +4850,8 @@ QDF_STATUS wma_set_passpoint_network_list(tp_wma_handle wma, params_len = sizeof(*params) + (req->num_networks * sizeof(struct wifi_passpoint_network_param)); params = qdf_mem_malloc(params_len); - if (params == NULL) { - WMA_LOGE(FL("memory allocation failed")); + if (!params) return QDF_STATUS_E_NOMEM; - } params->request_id = req->request_id; params->vdev_id = req->session_id; @@ -4961,10 +4914,8 @@ QDF_STATUS wma_reset_passpoint_network_list(tp_wma_handle wma, params_len = sizeof(*params) + (req->num_networks * sizeof(struct wifi_passpoint_network_param)); params = qdf_mem_malloc(params_len); - if (params == NULL) { - WMA_LOGE(FL("memory allocation failed")); + if (!params) return QDF_STATUS_E_NOMEM; - } params->request_id = req->request_id; params->vdev_id = req->session_id; @@ -5038,15 +4989,10 @@ void wma_roam_better_ap_handler(tp_wma_handle wma, uint32_t vdev_id) tSirSmeCandidateFoundInd *candidate_ind; candidate_ind = qdf_mem_malloc(sizeof(tSirSmeCandidateFoundInd)); - if (!candidate_ind) { - WMA_LOGE("%s: Alloc failed for tSirSmeCandidateFoundInd", - __func__); + if (!candidate_ind) return; - } - WMA_LOGD("%s: roaming in progress for vdev %d", - __func__, vdev_id); - wma->interfaces[vdev_id].roaming_in_progress = true; + wma->interfaces[vdev_id].roaming_in_progress = true; candidate_ind->messageType = eWNI_SME_CANDIDATE_FOUND_IND; candidate_ind->sessionId = vdev_id; candidate_ind->length = sizeof(tSirSmeCandidateFoundInd); @@ -5055,7 +5001,7 @@ void wma_roam_better_ap_handler(tp_wma_handle wma, uint32_t vdev_id) cds_msg.bodyptr = candidate_ind; cds_msg.callback = sme_mc_process_handler; QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_INFO, - FL("posting candidate ind to SME")); + FL("posting candidate ind to SME, vdev %d"), vdev_id); if (QDF_STATUS_SUCCESS != scheduler_post_message(QDF_MODULE_ID_WMA, QDF_MODULE_ID_SME, @@ -5080,12 +5026,10 @@ static void wma_handle_btm_disassoc_imminent_msg(tp_wma_handle wma_handle, { tpDeleteStaContext del_sta_ctx; - del_sta_ctx = - (tDeleteStaContext *)qdf_mem_malloc(sizeof(tDeleteStaContext)); - if (!del_sta_ctx) { - WMA_LOGE("Memory alloc failed for del sta context"); + del_sta_ctx = qdf_mem_malloc(sizeof(tDeleteStaContext)); + if (!del_sta_ctx) return; - } + del_sta_ctx->vdev_id = vdev_id; del_sta_ctx->reasonCode = HAL_DEL_STA_REASON_CODE_BTM_DISASSOC_IMMINENT; wma_send_msg(wma_handle, SIR_LIM_DELETE_STA_CONTEXT_IND, @@ -5180,10 +5124,9 @@ int wma_roam_event_callback(WMA_HANDLE handle, uint8_t *event_buf, #endif case WMI_ROAM_REASON_INVALID: roam_synch_data = qdf_mem_malloc(sizeof(*roam_synch_data)); - if (NULL == roam_synch_data) { - WMA_LOGE("Memory unavailable for roam synch data"); + if (!roam_synch_data) return -ENOMEM; - } + if (wmi_event->notif == WMI_ROAM_NOTIF_ROAM_START) { op_code = SIR_ROAMING_START; wma_handle->interfaces[wmi_event->vdev_id]. @@ -5208,10 +5151,9 @@ int wma_roam_event_callback(WMA_HANDLE handle, uint8_t *event_buf, break; case WMI_ROAM_REASON_INVOKE_ROAM_FAIL: roam_synch_data = qdf_mem_malloc(sizeof(*roam_synch_data)); - if (!roam_synch_data) { - WMA_LOGE("Memory unavailable for roam synch data"); + if (!roam_synch_data) return -ENOMEM; - } + roam_synch_data->roamedVdevId = wmi_event->vdev_id; wma_handle->csr_roam_synch_cb( (tpAniSirGlobal)wma_handle->mac_context, @@ -5281,10 +5223,8 @@ QDF_STATUS wma_ht40_stop_obss_scan(tp_wma_handle wma, int32_t vdev_id) int len = sizeof(*cmd); buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGP("%s: wmi_buf_alloc failed", __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } WMA_LOGD("cmd %x vdev_id %d", WMI_OBSS_SCAN_DISABLE_CMDID, vdev_id); @@ -5298,8 +5238,6 @@ QDF_STATUS wma_ht40_stop_obss_scan(tp_wma_handle wma, int32_t vdev_id) ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, WMI_OBSS_SCAN_DISABLE_CMDID); if (ret != EOK) { - WMA_LOGE("Failed to send gw config parameter to fw, ret: %d", - ret); wmi_buf_free(buf); return QDF_STATUS_E_FAILURE; } @@ -5342,10 +5280,8 @@ QDF_STATUS wma_send_ht40_obss_scanind(tp_wma_handle wma, req->obss_width_trigger_interval); buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGP("%s: wmi_buf_alloc failed", __func__); + if (!buf) return QDF_STATUS_E_NOMEM; - } cmd = (wmi_obss_scan_enable_cmd_fixed_param *) wmi_buf_data(buf); WMITLV_SET_HDR(&cmd->tlv_header, @@ -5397,8 +5333,6 @@ QDF_STATUS wma_send_ht40_obss_scanind(tp_wma_handle wma, ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, WMI_OBSS_SCAN_ENABLE_CMDID); if (ret != EOK) { - WMA_LOGE("Failed to send gw config parameter to fw, ret: %d", - ret); wmi_buf_free(buf); return QDF_STATUS_E_FAILURE; } diff --git a/core/wma/src/wma_utils.c b/core/wma/src/wma_utils.c index 7682aad0d0cd..ad9a865b444e 100644 --- a/core/wma/src/wma_utils.c +++ b/core/wma/src/wma_utils.c @@ -348,10 +348,9 @@ void wma_lost_link_info_handler(tp_wma_handle wma, uint32_t vdev_id, (WMI_VDEV_TYPE_STA == wma->interfaces[vdev_id].type) && (0 == wma->interfaces[vdev_id].sub_type)) { lost_link_info = qdf_mem_malloc(sizeof(*lost_link_info)); - if (NULL == lost_link_info) { - WMA_LOGE("%s: failed to allocate memory", __func__); + if (!lost_link_info) return; - } + lost_link_info->vdev_id = vdev_id; lost_link_info->rssi = rssi; sme_msg.type = eWNI_SME_LOST_LINK_INFO_IND; @@ -464,11 +463,9 @@ int wma_stats_ext_event_handler(void *handle, uint8_t *event_buf, stats_ext_info->data_len, param_buf->num_data); return -EINVAL; } - stats_ext_event = (tSirStatsExtEvent *) qdf_mem_malloc(alloc_len); - if (NULL == stats_ext_event) { - WMA_LOGE("%s: Memory allocation failure", __func__); + stats_ext_event = qdf_mem_malloc(alloc_len); + if (!stats_ext_event) return -ENOMEM; - } buf_ptr += sizeof(wmi_stats_ext_event_fixed_param) + WMI_TLV_HDR_SIZE; @@ -799,14 +796,12 @@ static tSirLLStatsResults *wma_get_ll_stats_ext_buf(uint32_t *len, return NULL; } - buf = (tSirLLStatsResults *)qdf_mem_malloc(buf_len); - if (buf == NULL) { - WMA_LOGE("%s: Cannot allocate link layer stats.", __func__); - buf_len = 0; - return NULL; - } + buf = qdf_mem_malloc(buf_len); + if (!buf) + *len = 0; + else + *len = buf_len; - *len = buf_len; return buf; } @@ -1343,11 +1338,8 @@ static int wma_unified_link_peer_stats_event_handler(void *handle, (total_num_rates * rate_stats_size); link_stats_results = qdf_mem_malloc(link_stats_results_size); - if (NULL == link_stats_results) { - WMA_LOGD("%s: could not allocate mem for stats results-len %zu", - __func__, link_stats_results_size); + if (!link_stats_results) return -ENOMEM; - } qdf_mem_zero(link_stats_results, link_stats_results_size); @@ -1556,8 +1548,6 @@ static int wma_unified_radio_tx_power_level_stats_event_handler(void *handle, sizeof(uint32_t) * rs_results->total_num_tx_power_levels); if (!rs_results->tx_time_per_power_level) { - WMA_LOGA("%s: Mem alloc fail for tx power level stats", - __func__); /* In error case, atleast send the radio stats without * tx_power_level stats */ rs_results->total_num_tx_power_levels = 0; @@ -1691,11 +1681,8 @@ static int wma_unified_link_radio_stats_event_handler(void *handle, if (!wma_handle->link_stats_results) { wma_handle->link_stats_results = qdf_mem_malloc( link_stats_results_size); - if (NULL == wma_handle->link_stats_results) { - WMA_LOGD("%s: could not allocate mem for stats results-len %zu", - __func__, link_stats_results_size); + if (!wma_handle->link_stats_results) return -ENOMEM; - } } link_stats_results = wma_handle->link_stats_results; if (link_stats_results->num_radio == 0) { @@ -1772,12 +1759,10 @@ static int wma_unified_link_radio_stats_event_handler(void *handle, rs_results->on_time_host_scan = radio_stats->on_time_host_scan; rs_results->on_time_lpi_scan = radio_stats->on_time_lpi_scan; if (rs_results->numChannels) { - rs_results->channels = (tSirWifiChannelStats *) qdf_mem_malloc( + rs_results->channels = qdf_mem_malloc( radio_stats->num_channels * chan_stats_size); - if (rs_results->channels == NULL) { - WMA_LOGD("%s: could not allocate mem for channel stats (size=%zu)", - __func__, radio_stats->num_channels * chan_stats_size); + if (!rs_results->channels) { wma_unified_radio_tx_mem_free(handle); return -ENOMEM; } @@ -1871,10 +1856,8 @@ static int wma_peer_ps_evt_handler(void *handle, u_int8_t *event, sizeof(tSirWifiPeerStat) + sizeof(tSirWifiPeerInfo); link_stats_results = qdf_mem_malloc(result_len); - if (link_stats_results == NULL) { - WMA_LOGE("%s: Cannot allocate link layer stats.", __func__); + if (!link_stats_results) return -EINVAL; - } WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_param->peer_macaddr, &mac_address[0]); WMA_LOGD("Peer power state change event from FW"); @@ -2168,11 +2151,8 @@ int wma_unified_link_iface_stats_event_handler(void *handle, link_stats_results_size = sizeof(*link_stats_results) + link_stats_size; link_stats_results = qdf_mem_malloc(link_stats_results_size); - if (!link_stats_results) { - WMA_LOGD("%s: could not allocate mem for stats results-len %zu", - __func__, link_stats_results_size); + if (!link_stats_results) return -ENOMEM; - } qdf_mem_zero(link_stats_results, link_stats_results_size); @@ -2266,10 +2246,8 @@ void wma_config_stats_ext_threshold(tp_wma_handle wma, sizeof(wmi_rx_stats_thresh) + 5 * WMI_TLV_HDR_SIZE; buf = wmi_buf_alloc(wma->wmi_handle, len); - if (!buf) { - WMA_LOGP("%s: wmi_buf_alloc failed", __func__); + if (!buf) return; - } buf_ptr = (u_int8_t *)wmi_buf_data(buf); tag = WMITLV_TAG_STRUC_wmi_pdev_set_stats_threshold_cmd_fixed_param; @@ -2382,10 +2360,8 @@ void wma_config_stats_ext_threshold(tp_wma_handle wma, WMI_PDEV_SET_STATS_THRESHOLD_CMDID, len); if (EOK != wmi_unified_cmd_send(wma->wmi_handle, buf, len, - WMI_PDEV_SET_STATS_THRESHOLD_CMDID)) { - WMA_LOGE("Failed to send WMI_PDEV_SET_STATS_THRESHOLD_CMDID"); + WMI_PDEV_SET_STATS_THRESHOLD_CMDID)) wmi_buf_free(buf); - } } #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ @@ -2927,10 +2903,8 @@ int wma_rso_cmd_status_event_handler(wmi_roam_event_fixed_param *wmi_event) QDF_STATUS qdf_status; rso_status = qdf_mem_malloc(sizeof(*rso_status)); - if (!rso_status) { - WMA_LOGE("%s: malloc fails for rso cmd status", __func__); + if (!rso_status) return -ENOMEM; - } rso_status->vdev_id = wmi_event->vdev_id; if (WMI_ROAM_NOTIF_SCAN_MODE_SUCCESS == wmi_event->notif) @@ -2992,10 +2966,9 @@ static void wma_handle_sta_peer_info(uint32_t num_peer_stats, } peer_info = qdf_mem_malloc(sizeof(*peer_info) + sizeof(peer_info->info[0])); - if (NULL == peer_info) { - WMA_LOGE("%s: Memory allocation failed.", __func__); + if (!peer_info) return; - } + if (i < num_peer_stats) { peer_info->count = 1; WMI_MAC_ADDR_TO_CHAR_ARRAY(&(peer_stats->peer_macaddr), @@ -3016,10 +2989,9 @@ static void wma_handle_sta_peer_info(uint32_t num_peer_stats, } else { peer_info = qdf_mem_malloc(sizeof(*peer_info) + num_peer_stats * sizeof(peer_info->info[0])); - if (NULL == peer_info) { - WMA_LOGE("%s: Memory allocation failed.", __func__); + if (!peer_info) return; - } + peer_info->count = num_peer_stats; for (i = 0; i < num_peer_stats; i++) { @@ -3303,10 +3275,9 @@ static QDF_STATUS wma_peer_info_ext_rsp(tp_wma_handle wma, u_int8_t *buf) if (wma->get_one_peer_info) { resp = qdf_mem_malloc(sizeof(struct sir_peer_info_ext_resp) + sizeof(resp->info[0])); - if (!resp) { - WMA_LOGE(FL("resp allocation failed.")); + if (!resp) return QDF_STATUS_E_NOMEM; - } + resp->count = 0; peer_info = &resp->info[0]; for (i = 0; i < event->num_peers; i++) { @@ -3326,10 +3297,9 @@ static QDF_STATUS wma_peer_info_ext_rsp(tp_wma_handle wma, u_int8_t *buf) } else { resp = qdf_mem_malloc(sizeof(struct sir_peer_info_ext_resp) + event->num_peers * sizeof(resp->info[0])); - if (!resp) { - WMA_LOGE(FL("resp allocation failed.")); + if (!resp) return QDF_STATUS_E_NOMEM; - } + resp->count = event->num_peers; for (i = 0; i < event->num_peers; i++) { peer_info = &resp->info[j]; @@ -3442,10 +3412,8 @@ int wma_peer_info_event_handler(void *handle, u_int8_t *cmd_param_info, buf_size = sizeof(wmi_peer_stats_info_event_fixed_param) + sizeof(wmi_peer_stats_info) * event->num_peers; buf = qdf_mem_malloc(buf_size); - if (!buf) { - WMA_LOGE("%s: Failed alloc memory for buf", __func__); + if (!buf) return -ENOMEM; - } qdf_mem_copy(buf, param_buf->fixed_param, sizeof(wmi_peer_stats_info_event_fixed_param)); @@ -3469,7 +3437,6 @@ int wma_peer_info_event_handler(void *handle, u_int8_t *cmd_param_info, */ QDF_STATUS wma_send_link_speed(uint32_t link_speed) { - QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; tpAniSirGlobal mac_ctx; tSirLinkSpeedInfo *ls_ind; @@ -3479,21 +3446,19 @@ QDF_STATUS wma_send_link_speed(uint32_t link_speed) return QDF_STATUS_E_INVAL; } - ls_ind = (tSirLinkSpeedInfo *)qdf_mem_malloc(sizeof(tSirLinkSpeedInfo)); - if (!ls_ind) { - WMA_LOGE("%s: Memory allocation failed.", __func__); - qdf_status = QDF_STATUS_E_NOMEM; - } else { - ls_ind->estLinkSpeed = link_speed; - if (mac_ctx->sme.pLinkSpeedIndCb) - mac_ctx->sme.pLinkSpeedIndCb(ls_ind, - mac_ctx->sme.pLinkSpeedCbContext); - else - WMA_LOGD("%s: pLinkSpeedIndCb is null", __func__); - qdf_mem_free(ls_ind); + ls_ind = qdf_mem_malloc(sizeof(tSirLinkSpeedInfo)); + if (!ls_ind) + return QDF_STATUS_E_NOMEM; - } - return qdf_status; + ls_ind->estLinkSpeed = link_speed; + if (mac_ctx->sme.pLinkSpeedIndCb) + mac_ctx->sme.pLinkSpeedIndCb(ls_ind, + mac_ctx->sme.pLinkSpeedCbContext); + else + WMA_LOGD("%s: pLinkSpeedIndCb is null", __func__); + qdf_mem_free(ls_ind); + + return QDF_STATUS_SUCCESS; } /** @@ -3914,7 +3879,6 @@ static tAniGetPEStatsRsp *wma_get_stats_rsp_buf stats_rsp_params = qdf_mem_malloc(len); if (!stats_rsp_params) { - WMA_LOGE("memory allocation failed for tAniGetPEStatsRsp"); QDF_ASSERT(0); return NULL; } @@ -4067,10 +4031,8 @@ void *wma_get_beacon_buffer_by_vdev_id(uint8_t vdev_id, uint32_t *buffer_size) buf_size = qdf_nbuf_len(beacon->buf); buf = qdf_mem_malloc(buf_size); - if (!buf) { qdf_spin_unlock_bh(&beacon->lock); - WMA_LOGE("%s: alloc failed for beacon buf", __func__); return NULL; } @@ -4472,10 +4434,8 @@ QDF_STATUS wma_get_rcpi_req(WMA_HANDLE handle, } node_rcpi_req = qdf_mem_malloc(sizeof(*node_rcpi_req)); - if (!node_rcpi_req) { - WMA_LOGE("Failed to allocate memory for rcpi_request"); + if (!node_rcpi_req) return QDF_STATUS_E_NOMEM; - } *node_rcpi_req = *rcpi_request; iface->rcpi_req = node_rcpi_req; @@ -4788,10 +4748,8 @@ QDF_STATUS wma_get_roam_scan_stats(WMA_HANDLE handle, } node_req = qdf_mem_malloc(sizeof(*node_req)); - if (!node_req) { - WMA_LOGE("Failed to allocate memory for roam scan stats req"); + if (!node_req) return QDF_STATUS_E_NOMEM; - } *node_req = *req; iface->roam_scan_stats_req = node_req; diff --git a/core/wma/src/wma_utils_ut.c b/core/wma/src/wma_utils_ut.c index 0fbd6041d209..c050b904524d 100644 --- a/core/wma/src/wma_utils_ut.c +++ b/core/wma/src/wma_utils_ut.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2016, 2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -55,11 +55,9 @@ void wma_set_dbs_capability_ut(uint32_t dbs) wma->hw_mode.hw_mode_list = qdf_mem_malloc(sizeof(*wma->hw_mode.hw_mode_list) * wma->num_dbs_hw_modes); - if (!wma->hw_mode.hw_mode_list) { - WMA_LOGE("%s: Memory allocation failed for UT-DBS", - __func__); + if (!wma->hw_mode.hw_mode_list) return; - } + wma->hw_mode.hw_mode_list[0] = 0x0000; }