diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 53898ac77a86..e6cd4804dd0a 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -296,7 +296,7 @@ static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac) /* following pointer contains array of pointers for tSmeCmd* */ sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd; pMac->sme.pSmeCmdBufAddr = qdf_mem_malloc(sme_cmd_ptr_ary_sz); - if (NULL == pMac->sme.pSmeCmdBufAddr) { + if (!pMac->sme.pSmeCmdBufAddr) { status = QDF_STATUS_E_NOMEM; goto end; } @@ -1162,10 +1162,9 @@ QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal) do { msg = qdf_mem_malloc(sizeof(*msg)); - if (!msg) { - sme_err("Memory allocation failed! for msg"); + if (!msg) return QDF_STATUS_E_NOMEM; - } + msg->messageType = eWNI_SME_SYS_READY_IND; msg->length = sizeof(*msg); msg->csr_roam_synch_cb = csr_roam_synch_callback; @@ -1381,12 +1380,10 @@ QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id) eCsrRoamResult roamResult; roamInfo = qdf_mem_malloc(sizeof(*roamInfo)); - if (!roamInfo) { - sme_err("mem alloc failed for roam info"); + if (!roamInfo) return QDF_STATUS_E_FAILURE; - } - roamInfo->dfs_event.sessionId = session_id; + roamInfo->dfs_event.sessionId = session_id; roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND; roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND; QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, @@ -1672,10 +1669,8 @@ QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId, /* Prepare the request to send to SME. */ pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd)); - if (NULL == pSmeBcnReportReq) { - sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME"); + if (!pSmeBcnReportReq) return QDF_STATUS_E_NOMEM; - } pSmeRrmContext->eseBcnReqInProgress = true; @@ -2684,11 +2679,9 @@ QDF_STATUS sme_get_ap_channel_from_scan_cache( return QDF_STATUS_E_FAILURE; } scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); - if (NULL == scan_filter) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("scan_filter mem alloc failed")); + if (!scan_filter) return QDF_STATUS_E_FAILURE; - } + qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0); if (NULL == profile) { scan_filter->EncryptionType.numEntries = 1; @@ -3046,11 +3039,8 @@ QDF_STATUS sme_get_channel_bonding_mode5_g(tHalHandle hHal, uint32_t *mode) } smeConfig = qdf_mem_malloc(sizeof(*smeConfig)); - if (!smeConfig) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: failed to alloc smeConfig", __func__); + if (!smeConfig) return QDF_STATUS_E_NOMEM; - } if (sme_get_config_param(hHal, smeConfig) != QDF_STATUS_SUCCESS) { QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, @@ -3085,11 +3075,8 @@ QDF_STATUS sme_get_channel_bonding_mode24_g(tHalHandle hHal, uint32_t *mode) } smeConfig = qdf_mem_malloc(sizeof(*smeConfig)); - if (!smeConfig) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: failed to alloc smeConfig", __func__); + if (!smeConfig) return QDF_STATUS_E_NOMEM; - } if (sme_get_config_param(hHal, smeConfig) != QDF_STATUS_SUCCESS) { QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, @@ -4092,10 +4079,8 @@ QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id, struct wep_update_default_key_idx *update_key; update_key = qdf_mem_malloc(sizeof(*update_key)); - if (!update_key) { - sme_err("Failed to allocate memory for update key"); + if (!update_key) return QDF_STATUS_E_NOMEM; - } update_key->session_id = session_id; update_key->default_idx = default_idx; @@ -4229,7 +4214,6 @@ QDF_STATUS sme_get_link_status(mac_handle_t mac_handle, if (QDF_IS_STATUS_SUCCESS(status)) { msg = qdf_mem_malloc(sizeof(*msg)); if (!msg) { - sme_err("Malloc failure"); sme_release_global_lock(&mac->sme); return QDF_STATUS_E_NOMEM; } @@ -4339,8 +4323,7 @@ QDF_STATUS sme_generic_change_country_code(tHalHandle hHal, status = sme_acquire_global_lock(&pMac->sme); if (QDF_IS_STATUS_SUCCESS(status)) { pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq)); - - if (NULL == pMsg) { + if (!pMsg) { sme_release_global_lock(&pMac->sme); return QDF_STATUS_E_NOMEM; } @@ -4402,11 +4385,8 @@ QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal, } pSession->dhcp_done = false; - pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd)); - if (NULL == pMsg) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for dhcp start", - __func__); + pMsg = qdf_mem_malloc(sizeof(tAniDHCPInd)); + if (!pMsg) { sme_release_global_lock(&pMac->sme); return QDF_STATUS_E_NOMEM; } @@ -4471,11 +4451,8 @@ QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal, } pSession->dhcp_done = true; - pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd)); - if (NULL == pMsg) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for dhcp stop", - __func__); + pMsg = qdf_mem_malloc(sizeof(tAniDHCPInd)); + if (!pMsg) { sme_release_global_lock(&pMac->sme); return QDF_STATUS_E_NOMEM; } @@ -4528,11 +4505,8 @@ QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t status = sme_acquire_global_lock(&pMac->sme); if (QDF_STATUS_SUCCESS == status) { - pMsg = (tAniTXFailMonitorInd *) - qdf_mem_malloc(sizeof(tAniTXFailMonitorInd)); - if (NULL == pMsg) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Failed to allocate memory", __func__); + pMsg = qdf_mem_malloc(sizeof(tAniTXFailMonitorInd)); + if (!pMsg) { sme_release_global_lock(&pMac->sme); return QDF_STATUS_E_NOMEM; } @@ -4745,17 +4719,13 @@ QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req) } oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req)); - if (!oem_data_req) { - sme_err("mem alloc failed"); + if (!oem_data_req) return QDF_STATUS_E_NOMEM; - } oem_data_req->data_len = hdd_oem_req->data_len; oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len); - if (!oem_data_req->data) { - sme_err("mem alloc failed"); + if (!oem_data_req->data) return QDF_STATUS_E_NOMEM; - } qdf_mem_copy(oem_data_req->data, hdd_oem_req->data, oem_data_req->data_len); @@ -4926,11 +4896,8 @@ QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id, return QDF_STATUS_E_FAILURE; } request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq)); - if (NULL == request_buf) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "Not able to allocate memory for keep alive request"); + if (!request_buf) return QDF_STATUS_E_NOMEM; - } qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid); qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq)); @@ -5013,8 +4980,7 @@ QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal, if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&mac_ctx->sme)) { msg = qdf_mem_malloc(sizeof(*msg)); - if (NULL == msg) { - sme_err("Not able to allocate memory"); + if (!msg) { sme_release_global_lock(&mac_ctx->sme); return QDF_STATUS_E_NOMEM; } @@ -5765,12 +5731,8 @@ QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId, } request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList)); - if (NULL == request_buf) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for 8023 Multicast List request", - __func__); + if (!request_buf) return QDF_STATUS_E_NOMEM; - } if (!csr_is_conn_state_connected_infra(pMac, sessionId) && !csr_is_ndi_started(pMac, sessionId)) { @@ -5894,12 +5856,8 @@ QDF_STATUS sme_set_max_tx_power_per_band(enum band_info band, int8_t dB) pMaxTxPowerPerBandParams = qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams)); - if (NULL == pMaxTxPowerPerBandParams) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s:Not able to allocate memory for pMaxTxPowerPerBandParams", - __func__); + if (!pMaxTxPowerPerBandParams) return QDF_STATUS_E_NOMEM; - } pMaxTxPowerPerBandParams->power = dB; pMaxTxPowerPerBandParams->bandInfo = band; @@ -5943,12 +5901,8 @@ QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid, MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0)); pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams)); - if (NULL == pMaxTxParams) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for pMaxTxParams", - __func__); + if (!pMaxTxParams) return QDF_STATUS_E_NOMEM; - } qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid); qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress); @@ -5985,11 +5939,8 @@ QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr) tSirMacAddr *pBaseMacAddr; pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr)); - if (NULL == pBaseMacAddr) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Not able to allocate memory for pBaseMacAddr")); + if (!pBaseMacAddr) return QDF_STATUS_E_NOMEM; - } qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr)); @@ -6040,12 +5991,8 @@ QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId, } pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams)); - if (NULL == pTxParams) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for pTxParams", - __func__); + if (!pTxParams) return QDF_STATUS_E_NOMEM; - } qdf_copy_macaddr(&pTxParams->bssId, &pBSSId); pTxParams->power = power; /* unit is dBm */ @@ -6552,10 +6499,9 @@ void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id, } params = qdf_mem_malloc(sizeof(*params)); - if (!params) { - sme_err("Mem alloc for HLP IE fails"); + if (!params) return; - } + if ((profile->hlp_ie_len + SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) { sme_err("HLP IE len exceeds %d", @@ -6924,10 +6870,8 @@ QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason) return QDF_STATUS_SUCCESS; } req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - sme_err("failed to allocated memory"); + if (!req) return QDF_STATUS_E_NOMEM; - } req->Command = ROAM_SCAN_OFFLOAD_STOP; if ((reason == eCsrForcedDisassoc) || reason == ecsr_driver_disabled) @@ -8205,9 +8149,7 @@ QDF_STATUS sme_get_peer_stats(tpAniSirGlobal mac, } /* serialize the req through MC thread */ message.bodyptr = qdf_mem_malloc(sizeof(req)); - if (NULL == message.bodyptr) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Memory allocation failed.", __func__); + if (!message.bodyptr) { sme_release_global_lock(&mac->sme); return QDF_STATUS_E_NOMEM; } @@ -8253,9 +8195,7 @@ QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req, /* serialize the req through MC thread */ message.bodyptr = qdf_mem_malloc(sizeof(req)); - if (NULL == message.bodyptr) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Memory allocation failed.", __func__); + if (!message.bodyptr) { sme_release_global_lock(&mac->sme); return QDF_STATUS_E_NOMEM; } @@ -8304,9 +8244,7 @@ QDF_STATUS sme_get_peer_info_ext(tHalHandle hal, /* serialize the req through MC thread */ message.bodyptr = qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req)); - if (NULL == message.bodyptr) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Memory allocation failed.", __func__); + if (!message.bodyptr) { sme_release_global_lock(&mac->sme); return QDF_STATUS_E_NOMEM; } @@ -8431,10 +8369,8 @@ sme_add_periodic_tx_ptrn(tHalHandle hal, SME_ENTER(); req_msg = qdf_mem_malloc(sizeof(*req_msg)); - if (!req_msg) { - sme_err("memory allocation failed"); + if (!req_msg) return QDF_STATUS_E_NOMEM; - } *req_msg = *addPeriodicTxPtrnParams; @@ -8482,10 +8418,8 @@ sme_del_periodic_tx_ptrn(tHalHandle hal, SME_ENTER(); req_msg = qdf_mem_malloc(sizeof(*req_msg)); - if (!req_msg) { - sme_err("memory allocation failed"); + if (!req_msg) return QDF_STATUS_E_NOMEM; - } *req_msg = *delPeriodicTxPtrnParams; @@ -8647,10 +8581,7 @@ QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData, pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *) qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams)); - if (NULL == pIbssInfoReqParams) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for dhcp start", - __func__); + if (!pIbssInfoReqParams) { sme_release_global_lock(&pMac->sme); return QDF_STATUS_E_NOMEM; } @@ -8914,8 +8845,6 @@ QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc) sme_utc = qdf_mem_malloc(sizeof(*sme_utc)); if (!sme_utc) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Malloc failed")); status = QDF_STATUS_E_NOMEM; goto end; } @@ -8964,8 +8893,6 @@ QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal, buf = qdf_mem_malloc(sizeof(*sme_timing_advert) + timing_advert->template_length); if (!buf) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Not able to allocate memory for start TA")); status = QDF_STATUS_E_NOMEM; goto end; } @@ -9016,8 +8943,6 @@ QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal, sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert)); if (!sme_timing_advert) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Not able to allocate memory for stop TA")); status = QDF_STATUS_E_NOMEM; goto end; } @@ -9204,8 +9129,6 @@ QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id, request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats)); if (!request) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Not able to allocate memory")); status = QDF_STATUS_E_NOMEM; goto end; } @@ -9260,8 +9183,6 @@ QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context, request->dcc_ndl_chan_list_len + request->dcc_ndl_active_state_list_len); if (!msg_body) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Failed to allocate memory")); status = QDF_STATUS_E_NOMEM; goto end; } @@ -9401,12 +9322,8 @@ QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value) return QDF_STATUS_E_FAILURE; request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd)); - if (NULL == request_buf) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for MODEM POWER STATE IND", - __func__); + if (!request_buf) return QDF_STATUS_E_NOMEM; - } request_buf->param = value; @@ -9441,12 +9358,8 @@ QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId, return QDF_STATUS_E_FAILURE; pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode)); - if (NULL == pHtOpMode) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for setting OP mode", - __func__); + if (!pHtOpMode) return QDF_STATUS_E_NOMEM; - } switch (channel_type) { case eHT_CHAN_HT20: @@ -9651,10 +9564,9 @@ int sme_set_addba_accept(tHalHandle hal, uint8_t session_id, int value) QDF_STATUS status; addba_accept = qdf_mem_malloc(sizeof(*addba_accept)); - if (!addba_accept) { - sme_err("mem alloc failed for addba_accept"); + if (!addba_accept) return -EIO; - } + addba_accept->session_id = session_id; addba_accept->addba_accept = value; qdf_mem_zero(&msg, sizeof(msg)); @@ -9709,10 +9621,9 @@ int sme_send_addba_req(tHalHandle hal, uint8_t session_id, uint8_t tid, return -EINVAL; } send_ba_req = qdf_mem_malloc(sizeof(*send_ba_req)); - if (!send_ba_req) { - sme_err("mem alloc failed"); + if (!send_ba_req) return -EIO; - } + qdf_mem_copy(send_ba_req->mac_addr, csr_session->connectedProfile.bssid.bytes, QDF_MAC_ADDR_SIZE); @@ -9868,11 +9779,9 @@ QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal, struct scheduler_msg msg = {0}; tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd)); - if (rate_upd == NULL) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "Rate update struct alloc failed"); + if (!rate_upd) return QDF_STATUS_E_FAILURE; - } + *rate_upd = *rateUpdateParams; if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE) @@ -9970,11 +9879,9 @@ QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle, struct scheduler_msg msg = {0}; srl = qdf_mem_malloc(sizeof(*srl)); - if (NULL == srl) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: fail to alloc short retry limit", __func__); + if (!srl) return QDF_STATUS_E_FAILURE; - } + sme_debug("session_id %d short retry limit count: %d", short_retry_limit_th->session_id, short_retry_limit_th->short_retry_limit); @@ -10018,11 +9925,9 @@ QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle, struct scheduler_msg msg = {0}; lrl = qdf_mem_malloc(sizeof(*lrl)); - if (NULL == lrl) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: fail to alloc long retry limit", __func__); + if (!lrl) return QDF_STATUS_E_FAILURE; - } + sme_debug("session_id %d long retry limit count: %d", long_retry_limit_th->session_id, long_retry_limit_th->long_retry_limit); @@ -10070,11 +9975,9 @@ QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle, wma_handle = cds_get_context(QDF_MODULE_ID_WMA); inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time)); - if (NULL == inactivity_time) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: fail to alloc inactivity_time", __func__); + if (!inactivity_time) return QDF_STATUS_E_FAILURE; - } + QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, FL("sta_inactivity_timeout: %d"), sta_inactivity_timer->sta_inactivity_timeout); @@ -10175,10 +10078,8 @@ QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val) status = sme_acquire_global_lock(&pMac->sme); if (QDF_STATUS_SUCCESS == status) { - auto_sh_cmd = (tSirAutoShutdownCmdParams *) - qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams)); - if (auto_sh_cmd == NULL) { - sme_err("Request Buffer Alloc Fail"); + auto_sh_cmd = qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams)); + if (!auto_sh_cmd) { sme_release_global_lock(&pMac->sme); return QDF_STATUS_E_NOMEM; } @@ -10227,10 +10128,8 @@ QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal) status = sme_acquire_global_lock(&pMac->sme); if (QDF_STATUS_SUCCESS == status) { - cauReq = (tSirChAvoidUpdateReq *) - qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq)); - if (NULL == cauReq) { - sme_err("Request Buffer Alloc Fail"); + cauReq = qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq)); + if (!cauReq) { sme_release_global_lock(&pMac->sme); return QDF_STATUS_E_NOMEM; } @@ -10278,13 +10177,16 @@ QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type) uint32_t *val; tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal); - val = qdf_mem_malloc(sizeof(*val)); - if (NULL == val || NULL == mac_ptr) { + if (!mac_ptr) { QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, "%s: Invalid pointer", __func__); - return QDF_STATUS_E_NOMEM; + return QDF_STATUS_E_INVAL; } + val = qdf_mem_malloc(sizeof(*val)); + if (!val) + return QDF_STATUS_E_NOMEM; + *val = filter_type; msg.type = SIR_HAL_SET_MIRACAST; @@ -10323,11 +10225,8 @@ QDF_STATUS sme_set_mas(uint32_t val) uint32_t *ptr_val; ptr_val = qdf_mem_malloc(sizeof(*ptr_val)); - if (NULL == ptr_val) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: could not allocate ptr_val", __func__); + if (!ptr_val) return QDF_STATUS_E_NOMEM; - } *ptr_val = val; @@ -10394,11 +10293,9 @@ static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac, uint32_t SessionId = pChnlParams->peSessionId; proam_info.channelChangeRespEvent = - (tSirChanChangeResponse *) qdf_mem_malloc(sizeof(tSirChanChangeResponse)); - if (NULL == proam_info.channelChangeRespEvent) { + if (!proam_info.channelChangeRespEvent) { status = QDF_STATUS_E_NOMEM; - sme_err("Channel Change Event Allocation Failed: %d\n", status); return status; } if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) { @@ -10516,12 +10413,9 @@ QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams struct scheduler_msg msg = {0}; tpAniSirGlobal pMac = PMAC_STRUCT(hHal); - pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt)); - if (NULL == pWmaParam) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: could not allocate tThermalMgmt", __func__); + pWmaParam = qdf_mem_malloc(sizeof(t_thermal_mgmt)); + if (!pWmaParam) return QDF_STATUS_E_NOMEM; - } pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled; pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod; @@ -10643,12 +10537,8 @@ QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx) tSirTxPowerLimit *tx_power_limit; tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit)); - if (!tx_power_limit) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Memory allocation for TxPowerLimit failed!", - __func__); + if (!tx_power_limit) return QDF_STATUS_E_FAILURE; - } *tx_power_limit = *psmetx; @@ -10778,8 +10668,7 @@ QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input) data_len = sizeof(tStatsExtRequest) + input->request_data_len; data = qdf_mem_malloc(data_len); - - if (data == NULL) + if (!data) return QDF_STATUS_E_NOMEM; data->vdev_id = session_id; @@ -11292,10 +11181,9 @@ sme_set_bss_hotlist(mac_handle_t mac_handle, /* per contract must make a copy of the params when messaging */ bodyptr = qdf_mem_malloc(sizeof(*bodyptr)); - if (!bodyptr) { - sme_err("buffer allocation failure"); + if (!bodyptr) return QDF_STATUS_E_NOMEM; - } + *bodyptr = *params; status = sme_acquire_global_lock(&mac->sme); @@ -11329,10 +11217,9 @@ sme_reset_bss_hotlist(mac_handle_t mac_handle, /* per contract must make a copy of the params when messaging */ bodyptr = qdf_mem_malloc(sizeof(*bodyptr)); - if (!bodyptr) { - sme_err("buffer allocation failure"); + if (!bodyptr) return QDF_STATUS_E_NOMEM; - } + *bodyptr = *params; status = sme_acquire_global_lock(&mac->sme); @@ -11366,10 +11253,9 @@ sme_set_significant_change(mac_handle_t mac_handle, /* per contract must make a copy of the params when messaging */ bodyptr = qdf_mem_malloc(sizeof(*bodyptr)); - if (!bodyptr) { - sme_err("buffer allocation failure"); + if (!bodyptr) return QDF_STATUS_E_NOMEM; - } + *bodyptr = *params; status = sme_acquire_global_lock(&mac->sme); @@ -11401,10 +11287,9 @@ sme_reset_significant_change(mac_handle_t mac_handle, /* per contract must make a copy of the params when messaging */ bodyptr = qdf_mem_malloc(sizeof(*bodyptr)); - if (!bodyptr) { - sme_err("buffer allocation failure"); + if (!bodyptr) return QDF_STATUS_E_NOMEM; - } + *bodyptr = *params; status = sme_acquire_global_lock(&mac->sme); @@ -11488,10 +11373,8 @@ QDF_STATUS sme_set_epno_list(tHalHandle hal, (input->num_networks * sizeof(struct wifi_epno_network)); req_msg = qdf_mem_malloc(len); - if (!req_msg) { - sme_err("qdf_mem_malloc failed"); + if (!req_msg) return QDF_STATUS_E_NOMEM; - } req_msg->num_networks = input->num_networks; req_msg->request_id = input->request_id; @@ -11567,10 +11450,8 @@ QDF_STATUS sme_set_passpoint_list(tHalHandle hal, len = sizeof(*req_msg) + (input->num_networks * sizeof(struct wifi_passpoint_network)); req_msg = qdf_mem_malloc(len); - if (!req_msg) { - sme_err("qdf_mem_malloc failed"); + if (!req_msg) return QDF_STATUS_E_NOMEM; - } req_msg->num_networks = input->num_networks; req_msg->request_id = input->request_id; @@ -11630,10 +11511,8 @@ QDF_STATUS sme_reset_passpoint_list(tHalHandle hal, SME_ENTER(); req_msg = qdf_mem_malloc(sizeof(*req_msg)); - if (!req_msg) { - sme_err("qdf_mem_malloc failed"); + if (!req_msg) return QDF_STATUS_E_NOMEM; - } req_msg->request_id = input->request_id; req_msg->session_id = input->session_id; @@ -11746,13 +11625,8 @@ QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal, } clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req)); - - if (!clear_stats_req) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ", - __func__); + if (!clear_stats_req) return QDF_STATUS_E_NOMEM; - } *clear_stats_req = *pclearStatsReq; @@ -11809,13 +11683,8 @@ QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq psetStatsReq->aggressiveStatisticsGathering); set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req)); - - if (!set_stats_req) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ", - __func__); + if (!set_stats_req) return QDF_STATUS_E_NOMEM; - } *set_stats_req = *psetStatsReq; @@ -11857,11 +11726,8 @@ QDF_STATUS sme_ll_stats_get_req(mac_handle_t mac_handle, tSirLLStatsGetReq *ll_stats_get_req; ll_stats_get_req = qdf_mem_malloc(sizeof(*ll_stats_get_req)); - - if (!ll_stats_get_req) { - sme_err("Unable to allocate memory for WMA_LL_STATS_GET_REQ"); + if (!ll_stats_get_req) return QDF_STATUS_E_NOMEM; - } *ll_stats_get_req = *get_stats_req; @@ -11992,11 +11858,9 @@ QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal, mac = PMAC_STRUCT(hal); thresh = qdf_mem_malloc(sizeof(*thresh)); - if (!thresh) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Fail to alloc mem", __func__); + if (!thresh) return QDF_STATUS_E_NOMEM; - } + *thresh = *threshold; status = sme_acquire_global_lock(&mac->sme); @@ -12205,13 +12069,8 @@ QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal, tpAniSirGlobal pMac = PMAC_STRUCT(hHal); pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo)); - - if (!pSmeDhcpSrvInfo) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD", - __func__); + if (!pSmeDhcpSrvInfo) return QDF_STATUS_E_NOMEM; - } *pSmeDhcpSrvInfo = *pDhcpSrvInfo; @@ -12268,11 +12127,8 @@ QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type, struct flashing_req_params *ledflashing; ledflashing = qdf_mem_malloc(sizeof(*ledflashing)); - if (!ledflashing) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "Not able to allocate memory for WMA_LED_TIMING_REQ"); + if (!ledflashing) return QDF_STATUS_E_NOMEM; - } ledflashing->req_id = 0; ledflashing->pattern_id = type; @@ -12407,13 +12263,8 @@ QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id, struct sir_stats_avg_factor *stats_factor; stats_factor = qdf_mem_malloc(sizeof(*stats_factor)); - - if (!stats_factor) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR", - __func__); + if (!stats_factor) return QDF_STATUS_E_NOMEM; - } status = sme_acquire_global_lock(&mac->sme); @@ -12466,13 +12317,8 @@ QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id, struct sir_guard_time_request *g_time; g_time = qdf_mem_malloc(sizeof(*g_time)); - - if (!g_time) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME", - __func__); + if (!g_time) return QDF_STATUS_E_NOMEM; - } status = sme_acquire_global_lock(&mac->sme); @@ -12527,10 +12373,8 @@ QDF_STATUS sme_wifi_start_logger(tHalHandle hal, len = sizeof(*req_msg); req_msg = qdf_mem_malloc(len); - if (!req_msg) { - sme_err("qdf_mem_malloc failed"); + if (!req_msg) return QDF_STATUS_E_NOMEM; - } req_msg->verbose_level = start_log.verbose_level; req_msg->is_iwpriv_command = start_log.is_iwpriv_command; @@ -13184,10 +13028,8 @@ QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal, SME_ENTER(); req_msg = qdf_mem_malloc(sizeof(*req_msg)); - if (!req_msg) { - sme_err("memory allocation failed"); + if (!req_msg) return QDF_STATUS_E_NOMEM; - } *req_msg = *input; @@ -13292,10 +13134,8 @@ QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list *msg) } req_msg = qdf_mem_malloc(sizeof(*req_msg)); - if (!req_msg) { - sme_err("qdf_mem_malloc failed"); + if (!req_msg) return QDF_STATUS_E_NOMEM; - } req_msg->band = BAND_ALL; if (CSR_IS_ROAM_INTRA_BAND_ENABLED(mac)) { @@ -13514,11 +13354,8 @@ QDF_STATUS sme_gateway_param_update(tHalHandle Hal, struct gateway_param_update_req *request_buf; request_buf = qdf_mem_malloc(sizeof(*request_buf)); - if (NULL == request_buf) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "Not able to allocate memory for gw param update request"); + if (!request_buf) return QDF_STATUS_E_NOMEM; - } *request_buf = *gw_params; @@ -13975,11 +13812,8 @@ QDF_STATUS sme_add_beacon_filter(tHalHandle hal, } filter_param = qdf_mem_malloc(sizeof(*filter_param)); - if (NULL == filter_param) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: fail to alloc filter_param", __func__); + if (!filter_param) return QDF_STATUS_E_FAILURE; - } filter_param->vdev_id = session_id; @@ -14022,11 +13856,8 @@ QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id) } filter_param = qdf_mem_malloc(sizeof(*filter_param)); - if (NULL == filter_param) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: fail to alloc filter_param", __func__); + if (!filter_param) return QDF_STATUS_E_FAILURE; - } filter_param->vdev_id = session_id; @@ -14067,13 +13898,7 @@ void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id, A_UINT16 tmp; msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req)); - - if (NULL == msg) - qdf_status = QDF_STATUS_E_FAILURE; - else - qdf_status = QDF_STATUS_SUCCESS; - - if (!QDF_IS_STATUS_SUCCESS(qdf_status)) + if (!msg) return; msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME; @@ -14156,12 +13981,8 @@ QDF_STATUS sme_set_apf_instructions(tHalHandle hal, set_offload = qdf_mem_malloc(sizeof(*set_offload) + req->current_length); - - if (NULL == set_offload) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Failed to alloc set_offload")); + if (!set_offload) return QDF_STATUS_E_NOMEM; - } set_offload->session_id = req->session_id; set_offload->filter_id = req->filter_id; @@ -14288,7 +14109,7 @@ QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id, struct sir_create_session *msg; msg = qdf_mem_malloc(sizeof(*msg)); - if (NULL != msg) { + if (!msg) { msg->type = eWNI_SME_MON_INIT_SESSION; msg->vdev_id = vdev_id; msg->msg_len = sizeof(*msg); @@ -14327,11 +14148,8 @@ QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal, struct adaptive_dwelltime_params *dwelltime_params; dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params)); - if (NULL == dwelltime_params) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: fail to alloc dwelltime_params", __func__); + if (!dwelltime_params) return QDF_STATUS_E_NOMEM; - } dwelltime_params->is_enabled = params->is_enabled; dwelltime_params->dwelltime_mode = params->dwelltime_mode; @@ -14366,10 +14184,8 @@ void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id) QDF_STATUS status = QDF_STATUS_E_FAILURE; p_msg = qdf_mem_malloc(sizeof(*p_msg)); - if (NULL == p_msg) { - sme_err("mem alloc failed for sme msg"); + if (!p_msg) return; - } p_msg->vdev_id = vdev_id; p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND; @@ -14411,8 +14227,7 @@ void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2) status = sme_acquire_global_lock(&mac_ctx->sme); if (QDF_STATUS_SUCCESS == status) { ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg)); - if (NULL == ht_vht_cfg) { - sme_err("mem alloc failed for ht_vht_cfg"); + if (!ht_vht_cfg) { sme_release_global_lock(&mac_ctx->sme); return; } @@ -14503,10 +14318,9 @@ QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id, } len = sizeof(*bss_color_msg); bss_color_msg = qdf_mem_malloc(len); - if (!bss_color_msg) { - sme_err("mem alloc failed"); + if (!bss_color_msg) return QDF_STATUS_E_NOMEM; - } + bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR; bss_color_msg->length = len; bss_color_msg->session_id = session_id; @@ -14578,11 +14392,9 @@ QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id, } req = qdf_mem_malloc(sizeof(*req)); - if (NULL == req) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: fail to alloc mac_pwr_dbg_args", __func__); + if (!req) return QDF_STATUS_E_FAILURE; - } + req->module_id = dbg_args->module_id; req->pdev_id = dbg_args->pdev_id; req->num_args = dbg_args->num_args; @@ -14659,11 +14471,9 @@ QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle, } sme_config = qdf_mem_malloc(sizeof(*sme_config)); - if (!sme_config) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("failed to allocate memory for sme_config")); + if (!sme_config) return QDF_STATUS_E_FAILURE; - } + qdf_mem_zero(sme_config, sizeof(*sme_config)); sme_get_config_param(hal_handle, sme_config); @@ -14868,11 +14678,9 @@ QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle, struct scheduler_msg msg = {0}; tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt)); - if (NULL == tx_fail_cnt) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: fail to alloc filter_param", __func__); + if (!tx_fail_cnt) return QDF_STATUS_E_FAILURE; - } + sme_debug("session_id: %d tx_fail_count: %d", session_id, tx_fail_count); tx_fail_cnt->session_id = session_id; @@ -14945,11 +14753,8 @@ QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info) } wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd)); - if (NULL == wow_pulse_set_cmd) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: fail to alloc wow_pulse_set_cmd", __func__); + if (!wow_pulse_set_cmd) return QDF_STATUS_E_NOMEM; - } *wow_pulse_set_cmd = *wow_pulse_set_info; @@ -15031,8 +14836,7 @@ QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal, tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); - if (NULL == scan_filter) { - sme_err("memory allocation failed"); + if (!scan_filter) { status = QDF_STATUS_E_NOMEM; goto free_scan_flter; } @@ -15048,8 +14852,7 @@ QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal, if (NULL == scan_filter->BSSIDs.bssid) { scan_filter->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr)); - if (scan_filter->BSSIDs.bssid == NULL) { - sme_err("malloc failed"); + if (!scan_filter->BSSIDs.bssid) { status = QDF_STATUS_E_NOMEM; goto free_scan_flter; } @@ -15108,8 +14911,7 @@ QDF_STATUS sme_get_beacon_frm(tHalHandle hal, struct csr_roam_profile *profile, uint32_t ie_len; scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); - if (NULL == scan_filter) { - sme_err("memory allocation failed"); + if (!scan_filter) { status = QDF_STATUS_E_NOMEM; goto free_scan_flter; } @@ -15125,8 +14927,7 @@ QDF_STATUS sme_get_beacon_frm(tHalHandle hal, struct csr_roam_profile *profile, if (NULL == scan_filter->BSSIDs.bssid) { scan_filter->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr)); - if (scan_filter->BSSIDs.bssid == NULL) { - sme_err("malloc failed"); + if (!scan_filter->BSSIDs.bssid) { status = QDF_STATUS_E_NOMEM; goto free_scan_flter; } @@ -15169,8 +14970,7 @@ QDF_STATUS sme_get_beacon_frm(tHalHandle hal, struct csr_roam_profile *profile, /* include mac header and fixed params along with IEs in frame */ *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len; *frame_buf = qdf_mem_malloc(*frame_len); - if (NULL == *frame_buf) { - sme_err("memory allocation failed"); + if (!*frame_buf) { status = QDF_STATUS_E_NOMEM; goto free_scan_flter; } @@ -15218,10 +15018,9 @@ QDF_STATUS sme_fast_reassoc(tHalHandle hal, struct csr_roam_profile *profile, return QDF_STATUS_E_FAILURE; } fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc)); - if (NULL == fastreassoc) { - sme_err("qdf_mem_malloc failed for fastreassoc"); + if (!fastreassoc) return QDF_STATUS_E_NOMEM; - } + /* if both are same then set the flag */ if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) { fastreassoc->is_same_bssid = true; @@ -15286,10 +15085,8 @@ QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id, struct scheduler_msg msg; pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache)); - if (!pmk_cache) { - sme_err("Memory allocation failure"); + if (!pmk_cache) return QDF_STATUS_E_NOMEM; - } qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0); @@ -15358,10 +15155,8 @@ QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal, struct scheduler_msg msg; arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param)); - if (arp_set_param == NULL) { - sme_err("Memory allocation failure"); + if (!arp_set_param) return QDF_STATUS_E_NOMEM; - } qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param)); @@ -15396,10 +15191,8 @@ QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal, struct scheduler_msg msg; arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param)); - if (arp_get_param == NULL) { - sme_err("Memory allocation failure"); + if (!arp_get_param) return QDF_STATUS_E_NOMEM; - } qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param)); @@ -15476,10 +15269,8 @@ QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal, } dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params)); - if (!dbs_scan_params) { - sme_err("fail to alloc dbs_scan_params"); + if (!dbs_scan_params) return QDF_STATUS_E_NOMEM; - } dbs_scan_params->num_clients = params->num_clients; dbs_scan_params->pdev_id = params->pdev_id; @@ -15510,12 +15301,9 @@ QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi) struct sme_rcpi_req *rcpi_req; rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req)); - if (rcpi_req == NULL) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: Not able to allocate memory for rcpi req", - __func__); + if (!rcpi_req) return QDF_STATUS_E_NOMEM; - } + qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req)); status = sme_acquire_global_lock(&pMac->sme); @@ -15664,10 +15452,8 @@ QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id, QDF_STATUS status = QDF_STATUS_SUCCESS; iwcmd = qdf_mem_malloc(sizeof(*iwcmd)); - if (!iwcmd) { - sme_err("Failed alloc memory for iwcmd"); + if (!iwcmd) return QDF_STATUS_E_NOMEM; - } qdf_mem_zero(iwcmd, sizeof(*iwcmd)); iwcmd->param_sec_value = 0; @@ -15872,10 +15658,8 @@ QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id, struct scheduler_msg msg = {0}; cmd = qdf_mem_malloc(sizeof(*cmd)); - if (!cmd) { - sme_err("qdf_mem_malloc failed for limit off channel"); + if (!cmd) return QDF_STATUS_E_NOMEM; - } cmd->vdev_id = vdev_id; cmd->is_tos_active = is_tos_active; @@ -16037,14 +15821,11 @@ int sme_get_bss_transition_status(tHalHandle hal, } conn_res = qdf_mem_malloc(sizeof(tCsrScanResultInfo)); - if (!conn_res) { - sme_err("Failed to allocate memory for conn_res"); + if (!conn_res) return QDF_STATUS_E_NOMEM; - } res = qdf_mem_malloc(sizeof(tCsrScanResultInfo)); if (!res) { - sme_err("Failed to allocate memory for conn_res"); status = QDF_STATUS_E_NOMEM; goto free; } @@ -16217,7 +15998,6 @@ QDF_STATUS sme_handle_sae_msg(tHalHandle hal, uint8_t session_id, sae_msg = qdf_mem_malloc(sizeof(*sae_msg)); if (!sae_msg) { qdf_status = QDF_STATUS_E_NOMEM; - sme_err("SAE: memory allocation failed"); } else { sae_msg->message_type = eWNI_SME_SEND_SAE_MSG; sae_msg->length = sizeof(*sae_msg); @@ -16322,10 +16102,8 @@ sme_get_roam_scan_stats(tHalHandle hal, roam_scan_stats_cb cb, void *context, struct sir_roam_scan_stats *req; req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - sme_err("Failed allocate memory for roam scan stats req"); + if (!req) return QDF_STATUS_E_NOMEM; - } req->vdev_id = vdev_id; req->cb = cb; diff --git a/core/sme/src/common/sme_ft_api.c b/core/sme/src/common/sme_ft_api.c index 41aba9ec5ace..da367cf7ac5b 100644 --- a/core/sme/src/common/sme_ft_api.c +++ b/core/sme/src/common/sme_ft_api.c @@ -35,11 +35,9 @@ void sme_ft_open(tHalHandle hHal, uint32_t sessionId) pSession->ftSmeContext.pUsrCtx = qdf_mem_malloc(sizeof(tFTRoamCallbackUsrCtx)); - - if (NULL == pSession->ftSmeContext.pUsrCtx) { - sme_err("Memory allocation failure"); + if (!pSession->ftSmeContext.pUsrCtx) return; - } + pSession->ftSmeContext.pUsrCtx->pMac = pMac; pSession->ftSmeContext.pUsrCtx->sessionId = sessionId; @@ -155,8 +153,7 @@ void sme_set_ft_ies(tHalHandle hal_ptr, uint32_t session_id, /* Save the FT IEs */ session->ftSmeContext.auth_ft_ies = qdf_mem_malloc(ft_ies_length); - if (NULL == session->ftSmeContext.auth_ft_ies) { - sme_err("Mem alloc failed for auth_ft_ies"); + if (!session->ftSmeContext.auth_ft_ies) { sme_release_global_lock(&mac_ctx->sme); return; } @@ -201,8 +198,7 @@ void sme_set_ft_ies(tHalHandle hal_ptr, uint32_t session_id, /* Save the FT IEs */ session->ftSmeContext.reassoc_ft_ies = qdf_mem_malloc(ft_ies_length); - if (NULL == session->ftSmeContext.reassoc_ft_ies) { - sme_err("Mem alloc fail for reassoc_ft_ie"); + if (!session->ftSmeContext.reassoc_ft_ies) { sme_release_global_lock(&mac_ctx->sme); return; } @@ -253,7 +249,7 @@ QDF_STATUS sme_ft_send_update_key_ind(tpAniSirGlobal mac, uint32_t session_id, msglen = sizeof(tSirFTUpdateKeyInfo); msg = qdf_mem_malloc(msglen); - if (NULL == msg) + if (!msg) return QDF_STATUS_E_NOMEM; msg->messageType = eWNI_SME_FT_UPDATE_KEY; diff --git a/core/sme/src/common/sme_power_save.c b/core/sme/src/common/sme_power_save.c index ed418863ce55..91e0e7c04be9 100644 --- a/core/sme/src/common/sme_power_save.c +++ b/core/sme/src/common/sme_power_save.c @@ -149,10 +149,9 @@ static QDF_STATUS sme_ps_enable_ps_req_params(tpAniSirGlobal mac_ctx, enum ps_state ps_state; enable_ps_req_params = qdf_mem_malloc(sizeof(*enable_ps_req_params)); - if (NULL == enable_ps_req_params) { - sme_err("Memory allocation failed for enable_ps_req_params"); + if (!enable_ps_req_params) return QDF_STATUS_E_NOMEM; - } + if (ps_param->uapsd_per_ac_bit_mask) { enable_ps_req_params->psSetting = eSIR_ADDON_ENABLE_UAPSD; sme_ps_fill_uapsd_req_params(mac_ctx, @@ -189,10 +188,8 @@ static QDF_STATUS sme_ps_disable_ps_req_params(tpAniSirGlobal mac_ctx, QDF_STATUS status = QDF_STATUS_SUCCESS; disable_ps_req_params = qdf_mem_malloc(sizeof(*disable_ps_req_params)); - if (NULL == disable_ps_req_params) { - sme_err("Memory allocation failed for sDisablePsParams"); + if (!disable_ps_req_params) return QDF_STATUS_E_NOMEM; - } disable_ps_req_params->psSetting = eSIR_ADDON_NOTHING; disable_ps_req_params->sessionid = session_id; @@ -223,10 +220,8 @@ static QDF_STATUS sme_ps_enable_uapsd_req_params(tpAniSirGlobal mac_ctx, enable_uapsd_req_params = qdf_mem_malloc(sizeof(*enable_uapsd_req_params)); - if (NULL == enable_uapsd_req_params) { - sme_err("Memory allocation failed for enable_uapsd_req_params"); + if (!enable_uapsd_req_params) return QDF_STATUS_E_NOMEM; - } sme_ps_fill_uapsd_req_params(mac_ctx, &enable_uapsd_req_params->uapsdParams, @@ -265,10 +260,8 @@ static QDF_STATUS sme_ps_disable_uapsd_req_params(tpAniSirGlobal mac_ctx, } disable_uapsd_req_params = qdf_mem_malloc(sizeof(*disable_uapsd_req_params)); - if (NULL == disable_uapsd_req_params) { - sme_err("Mem alloc failed for disable_uapsd_req_params"); + if (!disable_uapsd_req_params) return QDF_STATUS_E_NOMEM; - } disable_uapsd_req_params->sessionid = session_id; status = sme_post_ps_msg_to_wma(WMA_DISABLE_UAPSD_REQ, @@ -433,10 +426,8 @@ QDF_STATUS sme_ps_timer_flush_sync(tHalHandle hal, uint8_t session_id) } req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - sme_err("out of memory"); + if (!req) return QDF_STATUS_E_NOMEM; - } if (ps_parm->uapsd_per_ac_bit_mask) { req->psSetting = eSIR_ADDON_ENABLE_UAPSD; @@ -637,11 +628,8 @@ QDF_STATUS sme_set_ps_host_offload(tHalHandle hal_ctx, } request_buf = qdf_mem_malloc(sizeof(tSirHostOffloadReq)); - if (NULL == request_buf) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Not able to allocate memory for host offload request")); + if (!request_buf) return QDF_STATUS_E_NOMEM; - } qdf_copy_macaddr(&request->bssid, &session->connectedProfile.bssid); @@ -692,11 +680,9 @@ QDF_STATUS sme_set_ps_ns_offload(tHalHandle hal_ctx, qdf_copy_macaddr(&request->bssid, &session->connectedProfile.bssid); request_buf = qdf_mem_malloc(sizeof(*request_buf)); - if (NULL == request_buf) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "Not able to allocate memory for NS offload request"); + if (!request_buf) return QDF_STATUS_E_NOMEM; - } + *request_buf = *request; msg.type = WMA_SET_NS_OFFLOAD; diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c index 5f44ee3bdfb1..6155d35aa057 100644 --- a/core/sme/src/csr/csr_api_roam.c +++ b/core/sme/src/csr/csr_api_roam.c @@ -188,10 +188,8 @@ static QDF_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx, return QDF_STATUS_E_INVAL; roam_info = qdf_mem_malloc(sizeof(*roam_info)); - if (!roam_info) { - sme_err("qdf_mem_malloc failed for SAE"); + if (!roam_info) return QDF_STATUS_E_FAILURE; - } roam_info->sae_info = sae_info; @@ -520,13 +518,10 @@ static QDF_STATUS csr_roam_init_globals(tpAniSirGlobal pMac) * sizeof(struct csr_roam_session); csr_roam_roam_session = qdf_mem_malloc(buf_size); - if (csr_roam_roam_session) { pMac->roam.roamSession = csr_roam_roam_session; status = QDF_STATUS_SUCCESS; } else { - sme_err("%s: Failed to allocate %d bytes", - __func__, buf_size); status = QDF_STATUS_E_NOMEM; } @@ -767,12 +762,9 @@ static void csr_roam_arrange_ch_list(tpAniSirGlobal mac_ctx, if (!prefer_5g) return; - tmp_list = (tSirUpdateChanParam *) - qdf_mem_malloc(sizeof(tSirUpdateChanParam) * num_channel); - if (tmp_list == NULL) { - sme_err("Memory allocation failed"); + tmp_list = qdf_mem_malloc(sizeof(tSirUpdateChanParam) * num_channel); + if (!tmp_list) return; - } /* Fist copy Non-DFS 5g channels */ for (i = 0; i < num_channel; i++) { @@ -855,11 +847,8 @@ static void csr_roam_sort_channel_for_early_stop(tpAniSirGlobal mac_ctx, (sizeof(tSirUpdateChanParam) * num_channel); chan_list_greedy = qdf_mem_malloc(buf_size); chan_list_non_greedy = qdf_mem_malloc(buf_size); - if (!chan_list_greedy || !chan_list_non_greedy) { - QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, - "Failed to allocate memory for tSirUpdateChanList"); - return; - } + if (!chan_list_greedy || !chan_list_non_greedy) + goto scan_list_sort_error; /* * fixed_greedy_chan_list is an evaluated channel list based on most of * the enterprise wifi deployments and the order of the channels @@ -1073,12 +1062,9 @@ QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac) (sizeof(tSirUpdateChanParam) * (numChan)); csr_init_operating_classes((tHalHandle) pMac); - pChanList = (tSirUpdateChanList *) qdf_mem_malloc(bufLen); - if (!pChanList) { - QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, - "Failed to allocate memory for tSirUpdateChanList"); + pChanList = qdf_mem_malloc(bufLen); + if (!pChanList) return QDF_STATUS_E_NOMEM; - } for (i = 0; i < pScan->base_channels.numChannels; i++) { struct csr_sta_roam_policy_params *roam_policy = @@ -1800,8 +1786,7 @@ QDF_STATUS csr_create_bg_scan_roam_channel_list(tpAniSirGlobal pMac, qdf_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo. numOfChannels); - if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) { - sme_err("Memory Allocation for CFG Channel List failed"); + if (!pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) { pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0; return QDF_STATUS_E_NOMEM; } @@ -1924,9 +1909,7 @@ QDF_STATUS csr_create_roam_scan_channel_list(tpAniSirGlobal pMac, } currChannelListInfo->ChannelList = qdf_mem_malloc(outNumChannels * sizeof(uint8_t)); - if (NULL == currChannelListInfo->ChannelList) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL, - "Failed to allocate memory for roam scan channel list"); + if (!currChannelListInfo->ChannelList) { currChannelListInfo->numOfChannels = 0; return QDF_STATUS_E_NOMEM; } @@ -5901,10 +5884,9 @@ static enum csr_join_state csr_roam_join_next_bss(tpAniSirGlobal mac_ctx, } roam_info = qdf_mem_malloc(sizeof(*roam_info)); - if (!roam_info) { - sme_err("failed to allocate memory"); + if (!roam_info) return eCsrStopRoaming; - } + qdf_mem_copy(&roam_info->bssid, &session->joinFailStatusCode.bssId, sizeof(tSirMacAddr)); /* @@ -6722,12 +6704,8 @@ static void csr_roam_synch_clean_up(tpAniSirGlobal mac, uint8_t session_id) roam_offload_failed = qdf_mem_malloc( sizeof(struct roam_offload_synch_fail)); - if (NULL == roam_offload_failed) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: unable to allocate memory for roam synch fail", - __func__); + if (!roam_offload_failed) return; - } roam_offload_failed->session_id = session_id; msg.type = WMA_ROAM_OFFLOAD_SYNCH_FAIL; @@ -7245,7 +7223,6 @@ static QDF_STATUS populate_fils_params_join_rsp(tpAniSirGlobal mac_ctx, roam_info->fils_join_rsp = qdf_mem_malloc(sizeof(*fils_join_rsp)); if (!roam_info->fils_join_rsp) { - sme_err("fils_join_rsp malloc fails!"); status = QDF_STATUS_E_FAILURE; goto free_fils_join_rsp; } @@ -7255,7 +7232,6 @@ static QDF_STATUS populate_fils_params_join_rsp(tpAniSirGlobal mac_ctx, if (!roam_fils_info->fils_pmk) { qdf_mem_free(roam_info->fils_join_rsp); roam_info->fils_join_rsp = NULL; - sme_err("fils_pmk malloc fails!"); status = QDF_STATUS_E_FAILURE; goto free_fils_join_rsp; } @@ -7978,10 +7954,8 @@ static void update_profile_fils_info(struct csr_roam_profile *des_profile, des_profile->fils_con_info = qdf_mem_malloc(sizeof(struct cds_fils_connection_info)); - if (!des_profile->fils_con_info) { - sme_err("failed to allocate memory"); + if (!des_profile->fils_con_info) return; - } qdf_mem_copy(des_profile->fils_con_info, src_profile->fils_con_info, @@ -7989,10 +7963,8 @@ static void update_profile_fils_info(struct csr_roam_profile *des_profile, des_profile->hlp_ie = qdf_mem_malloc(src_profile->hlp_ie_len); - if (!des_profile->hlp_ie) { - sme_err("failed to allocate memory for hlp ie"); + if (!des_profile->hlp_ie) return; - } qdf_mem_copy(des_profile->hlp_ie, src_profile->hlp_ie, src_profile->hlp_ie_len); @@ -8220,11 +8192,8 @@ QDF_STATUS csr_roam_copy_connected_profile(tpAniSirGlobal pMac, qdf_mem_set(pDstProfile, sizeof(struct csr_roam_profile), 0); pDstProfile->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr)); - if (NULL == pDstProfile->BSSIDs.bssid) { + if (!pDstProfile->BSSIDs.bssid) { status = QDF_STATUS_E_NOMEM; - sme_err("failed to allocate memory for BSSID " - MAC_ADDRESS_STR, - MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes)); goto end; } pDstProfile->BSSIDs.numOfBSSIDs = 1; @@ -8233,11 +8202,8 @@ QDF_STATUS csr_roam_copy_connected_profile(tpAniSirGlobal pMac, if (pSrcProfile->SSID.length > 0) { pDstProfile->SSIDs.SSIDList = qdf_mem_malloc(sizeof(tCsrSSIDInfo)); - if (NULL == pDstProfile->SSIDs.SSIDList) { + if (!pDstProfile->SSIDs.SSIDList) { status = QDF_STATUS_E_NOMEM; - sme_err("failed to allocate memory for SSID " - MAC_ADDRESS_STR, - MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes)); goto end; } pDstProfile->SSIDs.numOfSSIDs = 1; @@ -8251,9 +8217,8 @@ QDF_STATUS csr_roam_copy_connected_profile(tpAniSirGlobal pMac, if (pSrcProfile->nAddIEAssocLength) { pDstProfile->pAddIEAssoc = qdf_mem_malloc(pSrcProfile->nAddIEAssocLength); - if (NULL == pDstProfile->pAddIEAssoc) { + if (!pDstProfile->pAddIEAssoc) { status = QDF_STATUS_E_NOMEM; - sme_err("failed to allocate mem for additional ie"); goto end; } pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength; @@ -8539,10 +8504,8 @@ QDF_STATUS csr_roam_connect(tpAniSirGlobal pMac, uint32_t sessionId, } first_ap_profile = qdf_mem_malloc(sizeof(*first_ap_profile)); - if (NULL == first_ap_profile) { - sme_err("malloc fails for first_ap_profile"); + if (!first_ap_profile) return QDF_STATUS_E_NOMEM; - } /* Initialize the count before proceeding with the Join requests */ pSession->join_bssid_count = 0; @@ -9238,14 +9201,9 @@ QDF_STATUS csr_roam_save_connected_information(tpAniSirGlobal pMac, if (pProfile->nAddIEAssocLength) { pConnectProfile->pAddIEAssoc = qdf_mem_malloc(pProfile->nAddIEAssocLength); - if (NULL == pConnectProfile->pAddIEAssoc) - status = QDF_STATUS_E_NOMEM; - else - status = QDF_STATUS_SUCCESS; - if (!QDF_IS_STATUS_SUCCESS(status)) { - sme_err("Failed to allocate memory for IE"); + if (!pConnectProfile->pAddIEAssoc) return QDF_STATUS_E_FAILURE; - } + pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength; qdf_mem_copy(pConnectProfile->pAddIEAssoc, @@ -10032,10 +9990,9 @@ csr_check_profile_in_scan_cache(tpAniSirGlobal mac_ctx, { QDF_STATUS status; *scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); - if (NULL == *scan_filter) { - sme_err("alloc for ScanFilter failed"); + if (!*scan_filter) return false; - } + (*scan_filter)->scan_filter_for_roam = 1; status = csr_roam_prepare_filter_from_profile(mac_ctx, &neighbor_roam_info->csrNeighborRoamProfile, @@ -10088,11 +10045,8 @@ void csr_roam_roaming_state_disassoc_rsp_processor(tpAniSirGlobal pMac, } roamInfo = qdf_mem_malloc(sizeof(*roamInfo)); - - if (!roamInfo) { - sme_err("failed to allocate memory"); + if (!roamInfo) return; - } if (CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac, sessionId)) { sme_debug("***eCsrNothingToJoin***"); @@ -10168,7 +10122,6 @@ void csr_roam_roaming_state_disassoc_rsp_processor(tpAniSirGlobal pMac, qdf_mem_free(roamInfo); return; } else { - sme_err("pCurRoamProfile memory alloc failed"); QDF_ASSERT(0); csr_dequeue_command(pMac); } @@ -10342,10 +10295,8 @@ void csr_roaming_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf) pIbssPeerInd = (tSmeIbssPeerInd *) pSmeRsp; sme_err("Peer departed ntf from LIM in joining state"); roam_info = qdf_mem_malloc(sizeof(*roam_info)); - if (!roam_info) { - sme_err("failed to allocate memory for roam_info"); + if (!roam_info) break; - } roam_info->staId = (uint8_t) pIbssPeerInd->staId; qdf_copy_macaddr(&roam_info->peerMac, &pIbssPeerInd->peer_addr); @@ -10933,10 +10884,8 @@ csr_create_fils_realm_hash(struct cds_fils_connection_info *fils_con_info, return false; hash = qdf_mem_malloc(SHA256_DIGEST_SIZE); - if (!hash) { - sme_err("malloc fails in fils realm"); + if (!hash) return false; - } data[0] = fils_con_info->realm; qdf_get_hash(SHA256_CRYPTO_TYPE, 1, data, @@ -11435,10 +11384,8 @@ csr_roam_chk_lnk_disassoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr) tSmeCmd *cmd; cmd = qdf_mem_malloc(sizeof(*cmd)); - if (NULL == cmd) { - sme_err("memory allocation failed for size: %zu", sizeof(*cmd)); + if (!cmd) return; - } /* * Check if AP dis-associated us because of MIC failure. If so, @@ -12301,10 +12248,9 @@ csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr) msg = qdf_mem_malloc(sizeof( struct sme_obss_ht40_scanind_msg)); - if (NULL == msg) { - sme_err("Malloc failed"); + if (!msg) return; - } + msg->msg_type = eWNI_SME_HT40_OBSS_SCAN_IND; msg->length = sizeof(struct sme_obss_ht40_scanind_msg); @@ -13007,10 +12953,8 @@ QDF_STATUS csr_process_del_sta_session_command(tpAniSirGlobal mac_ctx, QDF_STATUS status; del_sta_self_req = qdf_mem_malloc(sizeof(struct del_sta_self_params)); - if (NULL == del_sta_self_req) { - sme_err(" mem alloc failed for tDelStaSelfParams"); + if (!del_sta_self_req) return QDF_STATUS_E_NOMEM; - } qdf_mem_copy(del_sta_self_req->self_mac_addr, sme_command->u.delStaSessionCmd.selfMacAddr, @@ -13341,7 +13285,6 @@ int8_t csr_get_cfg_max_tx_power(tpAniSirGlobal pMac, uint8_t channel) uint16_t cfgId = 0; int8_t maxTxPwr = 0; uint8_t *pCountryInfo = NULL; - QDF_STATUS status; uint8_t count = 0; uint8_t firstChannel; uint8_t maxChannels; @@ -13356,16 +13299,9 @@ int8_t csr_get_cfg_max_tx_power(tpAniSirGlobal pMac, uint8_t channel) return maxTxPwr; pCountryInfo = qdf_mem_malloc(cfgLength); - if (NULL == pCountryInfo) - status = QDF_STATUS_E_NOMEM; - else - status = QDF_STATUS_SUCCESS; - if (status != QDF_STATUS_SUCCESS) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: failed to allocate memory, status = %d", - __func__, status); + if (!pCountryInfo) goto error; - } + if (wlan_cfg_get_str(pMac, cfgId, (uint8_t *)pCountryInfo, &cfgLength) != QDF_STATUS_SUCCESS) { goto error; @@ -16903,10 +16839,8 @@ QDF_STATUS csr_process_add_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg) WMI_UNIFIED_VDEV_SUBTYPE_P2P_DEVICE == rsp->sub_type))) { sme_debug("send SET IE msg to PE"); msg = qdf_mem_malloc(sizeof(*msg)); - if (NULL == msg) { - sme_err("Memory allocation failed"); + if (!msg) return QDF_STATUS_E_NOMEM; - } msg->msg_type = eWNI_SME_SET_IE_REQ; msg->session_id = rsp->session_id; @@ -16993,10 +16927,8 @@ QDF_STATUS csr_issue_add_sta_for_session_req(tpAniSirGlobal pMac, struct scheduler_msg msg = {0}; add_sta_self_req = qdf_mem_malloc(sizeof(struct add_sta_self_params)); - if (NULL == add_sta_self_req) { - sme_err("Unable to allocate memory for tAddSelfStaParams"); + if (!add_sta_self_req) return QDF_STATUS_E_NOMEM; - } if (!(pMac->mlme_cfg)) { pe_err("Mlme cfg NULL"); @@ -17509,10 +17441,9 @@ QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac, uint32_t statsMask, QDF_STATUS status = QDF_STATUS_SUCCESS; pMsg = qdf_mem_malloc(sizeof(tAniGetPEStatsReq)); - if (NULL == pMsg) { - sme_err("Failed to allocate mem for stats req "); + if (!pMsg) return QDF_STATUS_E_NOMEM; - } + /* need to initiate a stats request to PE */ pMsg->msgType = eWNI_SME_GET_STATISTICS_REQ; pMsg->msgLen = (uint16_t) sizeof(tAniGetPEStatsReq); @@ -17765,10 +17696,8 @@ struct csr_statsclient_reqinfo *csr_roam_insert_entry_into_list( true)) { pNewStaEntry = qdf_mem_malloc(sizeof(struct csr_statsclient_reqinfo)); - if (NULL == pNewStaEntry) { - sme_err("couldn't allocate memory for the entry"); + if (!pNewStaEntry) return NULL; - } pNewStaEntry->callback = pStaEntry->callback; pNewStaEntry->pContext = pStaEntry->pContext; @@ -17843,11 +17772,9 @@ QDF_STATUS csr_get_snr(tpAniSirGlobal pMac, uint32_t sessionId = CSR_SESSION_ID_INVALID; tAniGetSnrReq *pMsg; - pMsg = (tAniGetSnrReq *) qdf_mem_malloc(sizeof(tAniGetSnrReq)); - if (NULL == pMsg) { - sme_err("failed to allocate mem for req"); + pMsg = qdf_mem_malloc(sizeof(tAniGetSnrReq)); + if (!pMsg) return QDF_STATUS_E_NOMEM; - } status = csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId); if (!QDF_IS_STATUS_SUCCESS(status)) { @@ -18466,11 +18393,9 @@ csr_create_roam_scan_offload_request(tpAniSirGlobal mac_ctx, #endif /* FEATURE_WLAN_ESE */ req_buf = qdf_mem_malloc(sizeof(tSirRoamOffloadScanReq)); - if (NULL == req_buf) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "Mem alloc for roam scan offload req failed"); + if (!req_buf) return NULL; - } + req_buf->Command = command; /* * If command is STOP, then pass down ScanOffloadEnabled as Zero. This @@ -18831,10 +18756,8 @@ QDF_STATUS csr_invoke_neighbor_report_request(uint8_t session_id, } invoke_params = qdf_mem_malloc(sizeof(*invoke_params)); - if (!invoke_params) { - sme_err("Memory allocation failure"); + if (!invoke_params) return QDF_STATUS_E_NOMEM; - } invoke_params->vdev_id = session_id; invoke_params->send_resp_to_host = send_resp_to_host; @@ -19246,11 +19169,9 @@ csr_create_per_roam_request(tpAniSirGlobal mac_ctx, struct wmi_per_roam_config_req *req_buf = NULL; req_buf = qdf_mem_malloc(sizeof(struct wmi_per_roam_config_req)); - if (!req_buf) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "Mem alloc for per roam req failed"); + if (!req_buf) return NULL; - } + req_buf->vdev_id = session_id; req_buf->per_config.enable = mac_ctx->mlme_cfg->lfr.per_roam_enable; @@ -20456,10 +20377,8 @@ QDF_STATUS csr_roam_update_config(tpAniSirGlobal mac_ctx, uint8_t session_id, } msg = qdf_mem_malloc(sizeof(*msg)); - if (NULL == msg) { - sme_err("malloc failed"); + if (!msg) return QDF_STATUS_E_NOMEM; - } msg->messageType = eWNI_SME_UPDATE_CONFIG; msg->sme_session_id = session_id; @@ -20649,7 +20568,6 @@ QDF_STATUS csr_roam_start_beacon_req(tpAniSirGlobal pMac, tSirStartBeaconIndication *pMsg; pMsg = qdf_mem_malloc(sizeof(tSirStartBeaconIndication)); - if (!pMsg) return QDF_STATUS_E_NOMEM; @@ -20684,15 +20602,11 @@ csr_roam_modify_add_ies(tpAniSirGlobal pMac, /* following buffer will be freed by consumer (PE) */ pLocalBuffer = qdf_mem_malloc(pModifyIE->ieBufferlength); - - if (NULL == pLocalBuffer) { - sme_err("Memory Allocation Failure!!!"); + if (!pLocalBuffer) return QDF_STATUS_E_NOMEM; - } pModifyAddIEInd = qdf_mem_malloc(sizeof(tSirModifyIEsInd)); - if (NULL == pModifyAddIEInd) { - sme_err("Memory Allocation Failure!!!"); + if (!pModifyAddIEInd) { qdf_mem_free(pLocalBuffer); return QDF_STATUS_E_NOMEM; } @@ -20752,8 +20666,7 @@ csr_roam_update_add_ies(tpAniSirGlobal pMac, if (pUpdateIE->ieBufferlength != 0) { /* Following buffer will be freed by consumer (PE) */ pLocalBuffer = qdf_mem_malloc(pUpdateIE->ieBufferlength); - if (NULL == pLocalBuffer) { - sme_err("Memory Allocation Failure!!!"); + if (!pLocalBuffer) { return QDF_STATUS_E_NOMEM; } qdf_mem_copy(pLocalBuffer, pUpdateIE->pAdditionIEBuffer, @@ -20761,11 +20674,8 @@ csr_roam_update_add_ies(tpAniSirGlobal pMac, } pUpdateAddIEs = qdf_mem_malloc(sizeof(tSirUpdateIEsInd)); - if (NULL == pUpdateAddIEs) { - sme_err("Memory Allocation Failure!!!"); - if (pLocalBuffer != NULL) - qdf_mem_free(pLocalBuffer); - + if (!pUpdateAddIEs) { + qdf_mem_free(pLocalBuffer); return QDF_STATUS_E_NOMEM; } @@ -21367,13 +21277,11 @@ void csr_process_set_hw_mode(tpAniSirGlobal mac, tSmeCmd *command) len = sizeof(*cmd); cmd = qdf_mem_malloc(len); - if (!cmd) { - sme_err("Memory allocation failed"); + if (!cmd) /* Probably the fail response will also fail during malloc. * Still proceeding to send response! */ goto fail; - } /* For hidden SSID case, if there is any scan command pending * it needs to be cleared before issuing set HW mode @@ -21442,11 +21350,9 @@ fail: if (cmd) qdf_mem_free(cmd); param = qdf_mem_malloc(sizeof(*param)); - if (!param) { - sme_err( - "Malloc fail: Fail to send response to SME"); + if (!param) return; - } + sme_err("Sending set HW fail response to SME"); param->status = SET_HW_MODE_STATUS_ECANCELED; param->cfgd_hw_mode_index = 0; @@ -21485,13 +21391,11 @@ void csr_process_set_dual_mac_config(tpAniSirGlobal mac, tSmeCmd *command) len = sizeof(*cmd); cmd = qdf_mem_malloc(len); - if (!cmd) { - sme_err("Memory allocation failed"); + if (!cmd) /* Probably the fail response will also fail during malloc. * Still proceeding to send response! */ goto fail; - } cmd->message_type = eWNI_SME_SET_DUAL_MAC_CFG_REQ; cmd->length = len; @@ -21518,11 +21422,9 @@ void csr_process_set_dual_mac_config(tpAniSirGlobal mac, tSmeCmd *command) return; fail: param = qdf_mem_malloc(sizeof(*param)); - if (!param) { - sme_err( - "Malloc fail: Fail to send response to SME"); + if (!param) return; - } + sme_err("Sending set dual mac fail response to SME"); param->status = SET_HW_MODE_STATUS_ECANCELED; msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP; @@ -21560,10 +21462,8 @@ void csr_process_set_antenna_mode(tpAniSirGlobal mac, tSmeCmd *command) len = sizeof(*cmd); cmd = qdf_mem_malloc(len); - if (!cmd) { - sme_err("Memory allocation failed"); + if (!cmd) goto fail; - } cmd->message_type = eWNI_SME_SET_ANTENNA_MODE_REQ; cmd->length = len; @@ -21587,11 +21487,9 @@ void csr_process_set_antenna_mode(tpAniSirGlobal mac, tSmeCmd *command) return; fail: param = qdf_mem_malloc(sizeof(*param)); - if (!param) { - sme_err( - "Malloc fail: Fail to send response to SME"); + if (!param) return; - } + sme_err("Sending set dual mac fail response to SME"); param->status = SET_ANTENNA_MODE_STATUS_ECANCELED; msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP; @@ -21628,13 +21526,11 @@ void csr_process_nss_update_req(tpAniSirGlobal mac, tSmeCmd *command) len = sizeof(*msg); msg = qdf_mem_malloc(len); - if (!msg) { - sme_err("Memory allocation failed"); + if (!msg) /* Probably the fail response is also fail during malloc. * Still proceeding to send response! */ goto fail; - } msg->msgType = eWNI_SME_NSS_UPDATE_REQ; msg->msgLen = sizeof(*msg); @@ -21652,11 +21548,9 @@ void csr_process_nss_update_req(tpAniSirGlobal mac, tSmeCmd *command) return; fail: param = qdf_mem_malloc(sizeof(*param)); - if (!param) { - sme_err( - "Malloc fail: Fail to send response to SME"); + if (!param) return; - } + sme_err("Sending nss update fail response to SME"); param->tx_status = QDF_STATUS_E_FAILURE; param->session_id = command->u.nss_update_cmd.session_id; @@ -21694,10 +21588,8 @@ static void csr_copy_fils_join_rsp_roam_info(struct csr_roam_info *roam_info, struct fils_join_rsp_params *roam_fils_info; roam_info->fils_join_rsp = qdf_mem_malloc(sizeof(*roam_fils_info)); - if (!roam_info->fils_join_rsp) { - sme_err("fils_join_rsp malloc fails!"); + if (!roam_info->fils_join_rsp) return; - } roam_fils_info = roam_info->fils_join_rsp; cds_copy_hlp_info(&roam_synch_data->dst_mac, @@ -21836,9 +21728,7 @@ static QDF_STATUS csr_process_roam_sync_callback(tpAniSirGlobal mac_ctx, ps_global_info->remain_in_power_active_till_dhcp = false; session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED; roam_info = qdf_mem_malloc(sizeof(struct csr_roam_info)); - if (NULL == roam_info) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, - FL("LFR3: Mem Alloc failed for roam info")); + if (!roam_info) { session->roam_synch_in_progress = false; qdf_mem_free(ies_local); return QDF_STATUS_E_NOMEM; @@ -21939,8 +21829,7 @@ static QDF_STATUS csr_process_roam_sync_callback(tpAniSirGlobal mac_ctx, SIR_MAC_HDR_LEN_3A; roam_info->pbFrames = qdf_mem_malloc(roam_info->nBeaconLength + roam_info->nAssocReqLength + roam_info->nAssocRspLength); - if (NULL == roam_info->pbFrames) { - sme_err("no memory available"); + if (!roam_info->pbFrames) { session->roam_synch_in_progress = false; if (roam_info) qdf_mem_free(roam_info); diff --git a/core/sme/src/csr/csr_api_scan.c b/core/sme/src/csr/csr_api_scan.c index 6739f2749fa8..9ae178a1bbec 100644 --- a/core/sme/src/csr/csr_api_scan.c +++ b/core/sme/src/csr/csr_api_scan.c @@ -300,10 +300,8 @@ QDF_STATUS csr_scan_handle_search_for_ssid_failure(tpAniSirGlobal mac_ctx, } roam_info = qdf_mem_malloc(sizeof(struct csr_roam_info)); - if (!roam_info) { - sme_err("Failed to allocate memory for roam_info"); + if (!roam_info) goto roam_completion; - } if (session->scan_info.roambssentry) { scan_result = GET_BASE_ADDR(session->scan_info.roambssentry, @@ -430,11 +428,9 @@ static void csr_scan_add_result(tpAniSirGlobal mac_ctx, buf = qdf_nbuf_alloc(NULL, qdf_roundup(buf_len, 4), 0, 4, false); - if (!buf) { - sme_err("Failed to allocate wbuf for mgmt rx len (%u)", - buf_len); + if (!buf) return; - } + qdf_nbuf_put_tail(buf, buf_len); qdf_nbuf_set_protocol(buf, ETH_P_CONTROL); @@ -500,10 +496,8 @@ static bool csr_scan_save_bss_description(tpAniSirGlobal pMac, cbAllocated = sizeof(struct tag_csrscan_result) + cbBSSDesc; pCsrBssDescription = qdf_mem_malloc(cbAllocated); - if (!pCsrBssDescription) { - sme_err(" Failed to allocate memory for pCsrBssDescription"); + if (!pCsrBssDescription) return false; - } pCsrBssDescription->AgingCount = (int32_t) pMac->roam.configParam.agingCount; @@ -1203,10 +1197,8 @@ static QDF_STATUS csr_save_profile(tpAniSirGlobal mac_ctx, sizeof(scan_result->Result.BssDescriptor.length); temp = qdf_mem_malloc(sizeof(struct tag_csrscan_result) + bss_len); - if (!temp) { - sme_err("bss mem fail"); + if (!temp) goto error; - } temp->AgingCount = scan_result->AgingCount; temp->preferValue = scan_result->preferValue; @@ -1494,11 +1486,8 @@ QDF_STATUS csr_scan_for_ssid(tpAniSirGlobal mac_ctx, uint32_t session_id, session->scan_info.scan_reason = eCsrScanForSsid; session->scan_info.roam_id = roam_id; req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Failed to allocate memory")); + if (!req) goto error; - } vdev = wlan_objmgr_get_vdev_by_macaddr_from_psoc(mac_ctx->psoc, pdev_id, @@ -1817,10 +1806,8 @@ QDF_STATUS csr_scan_abort_mac_scan(tpAniSirGlobal mac_ctx, uint32_t vdev_id, struct wlan_objmgr_vdev *vdev; req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - sme_err("Failed to allocate memory"); + if (!req) return QDF_STATUS_E_NOMEM; - } /* Get NL global context from objmgr*/ if (vdev_id == INVAL_VDEV_ID) @@ -1944,10 +1931,9 @@ QDF_STATUS csr_scan_create_entry_in_scan_cache(tpAniSirGlobal pMac, return QDF_STATUS_E_FAILURE; } pNewBssDescriptor = qdf_mem_malloc(size); - if (NULL == pNewBssDescriptor) { - sme_err("memory allocation failed"); + if (pNewBssDescriptor) return QDF_STATUS_E_FAILURE; - } + qdf_mem_copy(pNewBssDescriptor, pSession->pConnectBssDesc, size); /* change the BSSID & channel as passed */ qdf_mem_copy(pNewBssDescriptor->bssId, bssid.bytes, @@ -2005,11 +1991,8 @@ QDF_STATUS csr_scan_save_roam_offload_ap_to_scan_cache(tpAniSirGlobal pMac, (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET); scan_res_ptr = qdf_mem_malloc(sizeof(struct tag_csrscan_result) + length); - if (scan_res_ptr == NULL) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - " fail to allocate memory for frame"); + if (!scan_res_ptr) return QDF_STATUS_E_NOMEM; - } qdf_mem_copy(&scan_res_ptr->Result.BssDescriptor, bss_desc_ptr, @@ -2660,11 +2643,8 @@ static QDF_STATUS csr_fill_bss_from_scan_entry(tpAniSirGlobal mac_ctx, ieFields[0]) + ie_len); alloc_len = sizeof(struct tag_csrscan_result) + bss_len; bss = qdf_mem_malloc(alloc_len); - - if (!bss) { - sme_err("could not allocate bss"); + if (!bss) return QDF_STATUS_E_NOMEM; - } bss->AgingCount = (int32_t) mac_ctx->roam.configParam.agingCount; @@ -2966,7 +2946,6 @@ QDF_STATUS csr_scan_get_result(tpAniSirGlobal mac_ctx, ret_list = qdf_mem_malloc(sizeof(struct scan_result_list)); if (!ret_list) { - sme_err("pRetList is NULL"); status = QDF_STATUS_E_NOMEM; goto error; } @@ -3018,14 +2997,11 @@ QDF_STATUS csr_scan_get_result_for_bssid(tpAniSirGlobal mac_ctx, } scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); - if (!scan_filter) { - sme_err("Failed to allocated memory for scan_filter"); + if (!scan_filter) return QDF_STATUS_E_NOMEM; - } scan_filter->BSSIDs.bssid = qdf_mem_malloc(sizeof(*bssid)); if (!scan_filter->BSSIDs.bssid) { - sme_err("Failed to allocate memory for BSSIDs"); status = QDF_STATUS_E_FAILURE; goto free_filter; } diff --git a/core/sme/src/csr/csr_host_scan_roam.c b/core/sme/src/csr/csr_host_scan_roam.c index 8c3cc20adfba..79d419e67719 100644 --- a/core/sme/src/csr/csr_host_scan_roam.c +++ b/core/sme/src/csr/csr_host_scan_roam.c @@ -323,10 +323,9 @@ void csr_neighbor_roam_process_scan_results(tpAniSirGlobal mac_ctx, /* Finished all checks, now add it to candidate list */ bss_info = qdf_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo)); - if (NULL == bss_info) { - sme_err("Memory alloc fail"); + if (!bss_info) continue; - } + bss_info->pBssDescription = qdf_mem_malloc(descr->length + sizeof(descr->length)); @@ -334,7 +333,6 @@ void csr_neighbor_roam_process_scan_results(tpAniSirGlobal mac_ctx, qdf_mem_copy(bss_info->pBssDescription, descr, descr->length + sizeof(descr->length)); } else { - sme_err("Memory alloc fail"); qdf_mem_free(bss_info); continue; } diff --git a/core/sme/src/csr/csr_neighbor_roam.c b/core/sme/src/csr/csr_neighbor_roam.c index 2b58f77a69e2..5d021a3e61a0 100644 --- a/core/sme/src/csr/csr_neighbor_roam.c +++ b/core/sme/src/csr/csr_neighbor_roam.c @@ -103,9 +103,7 @@ void csr_neighbor_roam_send_lfr_metric_event( struct csr_roam_info *roam_info; roam_info = qdf_mem_malloc(sizeof(struct csr_roam_info)); - if (NULL == roam_info) { - sme_err("Memory allocation failed!"); - } else { + if (roam_info) { qdf_mem_copy((void *)roam_info->bssid.bytes, (void *)bssid, sizeof(struct qdf_mac_addr)); csr_roam_call_callback(mac_ctx, session_id, roam_info, 0, @@ -374,10 +372,8 @@ csr_neighbor_roam_prepare_scan_profile_filter(tpAniSirGlobal pMac, pScanFilter->BSSIDs.bssid = qdf_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs); - if (NULL == pScanFilter->BSSIDs.bssid) { - sme_err("Scan Filter BSSID mem alloc failed"); + if (!pScanFilter->BSSIDs.bssid) return QDF_STATUS_E_NOMEM; - } /* Populate the BSSID from handoff info received from HDD */ for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++) { @@ -394,10 +390,9 @@ csr_neighbor_roam_prepare_scan_profile_filter(tpAniSirGlobal pMac, pScanFilter->SSIDs.SSIDList = qdf_mem_malloc(sizeof(tCsrSSIDInfo) * pScanFilter->SSIDs.numOfSSIDs); - if (NULL == pScanFilter->SSIDs.SSIDList) { - sme_err("Scan Filter SSID mem alloc failed"); + if (!pScanFilter->SSIDs.SSIDList) return QDF_STATUS_E_NOMEM; - } + for (i = 0; i < roam_params->num_ssid_allowed_list; i++) { pScanFilter->SSIDs.SSIDList[i].handoffPermitted = 1; pScanFilter->SSIDs.SSIDList[i].ssidHidden = 0; @@ -413,10 +408,9 @@ csr_neighbor_roam_prepare_scan_profile_filter(tpAniSirGlobal pMac, pScanFilter->SSIDs.numOfSSIDs = 1; pScanFilter->SSIDs.SSIDList = qdf_mem_malloc(sizeof(tCsrSSIDInfo)); - if (NULL == pScanFilter->SSIDs.SSIDList) { - sme_err("Scan Filter SSID mem alloc failed"); + if (!pScanFilter->SSIDs.SSIDList) return QDF_STATUS_E_NOMEM; - } + pScanFilter->SSIDs.SSIDList->handoffPermitted = 1; pScanFilter->SSIDs.SSIDList->ssidHidden = 0; pScanFilter->SSIDs.SSIDList->SSID.length = @@ -453,8 +447,7 @@ csr_neighbor_roam_prepare_scan_profile_filter(tpAniSirGlobal pMac, pScanFilter->ChannelInfo.numOfChannels = num_ch; pScanFilter->ChannelInfo.ChannelList = qdf_mem_malloc(num_ch * sizeof(uint8_t)); - if (NULL == pScanFilter->ChannelInfo.ChannelList) { - sme_err("Scan Filter Ch list mem alloc failed"); + if (!pScanFilter->ChannelInfo.ChannelList) { qdf_mem_free(pScanFilter->SSIDs.SSIDList); pScanFilter->SSIDs.SSIDList = NULL; return QDF_STATUS_E_NOMEM; @@ -1277,11 +1270,9 @@ QDF_STATUS csr_neighbor_roam_init(tpAniSirGlobal pMac, uint8_t sessionId) pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = qdf_mem_malloc(pMac->roam.configParam.neighborRoamConfig. neighborScanChanList.numChannels); - if (NULL == - pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) { - sme_err("Memory Allocation for CFG Channel List failed"); + if (!pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) return QDF_STATUS_E_NOMEM; - } + } else { pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL; } @@ -1491,10 +1482,9 @@ static QDF_STATUS csr_neighbor_roam_process_handoff_req( roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam); profile = qdf_mem_malloc(sizeof(struct csr_roam_profile)); - if (NULL == profile) { - sme_err("Memory alloc failed"); + if (!profile) return QDF_STATUS_E_NOMEM; - } + status = csr_roam_copy_profile(mac_ctx, profile, session->pCurRoamProfile); @@ -1508,8 +1498,7 @@ static QDF_STATUS csr_neighbor_roam_process_handoff_req( profile->BSSIDs.bssid = qdf_mem_malloc(sizeof(tSirMacAddr) * profile->BSSIDs.numOfBSSIDs); - if (NULL == profile->BSSIDs.bssid) { - sme_err("mem alloc failed for BSSID"); + if (!profile->BSSIDs.bssid) { status = QDF_STATUS_E_NOMEM; goto end; } @@ -1527,8 +1516,7 @@ static QDF_STATUS csr_neighbor_roam_process_handoff_req( qdf_mem_malloc(sizeof(*profile-> ChannelInfo.ChannelList) * profile->ChannelInfo.numOfChannels); - if (NULL == profile->ChannelInfo.ChannelList) { - sme_err("mem alloc failed for ChannelList"); + if (!profile->ChannelInfo.ChannelList) { status = QDF_STATUS_E_NOMEM; goto end; } diff --git a/core/sme/src/csr/csr_roam_preauth.c b/core/sme/src/csr/csr_roam_preauth.c index d90411ae3d77..5c9e346bdf14 100644 --- a/core/sme/src/csr/csr_roam_preauth.c +++ b/core/sme/src/csr/csr_roam_preauth.c @@ -524,21 +524,16 @@ QDF_STATUS csr_roam_issue_ft_preauth_req(tpAniSirGlobal mac_ctx, } auth_req_len = sizeof(tSirFTPreAuthReq); - preauth_req = (tpSirFTPreAuthReq) qdf_mem_malloc(auth_req_len); - if (NULL == preauth_req) { - sme_err("Memory allocation for FT Preauth request failed"); + preauth_req = qdf_mem_malloc(auth_req_len); + if (!preauth_req) return QDF_STATUS_E_NOMEM; - } + /* Save the SME Session ID. We need it while processing preauth resp */ csr_session->ftSmeContext.smeSessionId = session_id; - - preauth_req->pbssDescription = - (tpSirBssDescription) qdf_mem_malloc(sizeof(bss_desc->length) + preauth_req->pbssDescription = qdf_mem_malloc(sizeof(bss_desc->length) + bss_desc->length); - if (NULL == preauth_req->pbssDescription) { - sme_err("Memory allocation for FT Preauth request failed"); + if (!preauth_req->pbssDescription) return QDF_STATUS_E_NOMEM; - } preauth_req->messageType = eWNI_SME_FT_PRE_AUTH_REQ; @@ -694,10 +689,9 @@ void csr_roam_ft_pre_auth_rsp_processor(tpAniSirGlobal mac_ctx, csr_session->ftSmeContext.reassoc_ft_ies = qdf_mem_malloc(ft_ies_length); - if (NULL == csr_session->ftSmeContext.reassoc_ft_ies) { - sme_err("Memory allocation failed for ft_ies"); + if (!csr_session->ftSmeContext.reassoc_ft_ies) return; - } + /* Copy the RIC IEs to reassoc IEs */ qdf_mem_copy(((uint8_t *) csr_session->ftSmeContext. reassoc_ft_ies), diff --git a/core/sme/src/nan/nan_api.c b/core/sme/src/nan/nan_api.c index c2fd88532b59..1c7a0423f00a 100644 --- a/core/sme/src/nan/nan_api.c +++ b/core/sme/src/nan/nan_api.c @@ -87,12 +87,9 @@ QDF_STATUS sme_nan_request(tpNanRequestReq input) data_len = sizeof(tNanRequest) + input->request_data_len; data = qdf_mem_malloc(data_len); - - if (data == NULL) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Memory allocation failure")); + if (!data) return QDF_STATUS_E_NOMEM; - } + data->request_data_len = input->request_data_len; if (input->request_data_len) { qdf_mem_copy(data->request_data, diff --git a/core/sme/src/qos/sme_qos.c b/core/sme/src/qos/sme_qos.c index a56c1721be5d..a7efae298400 100644 --- a/core/sme/src/qos/sme_qos.c +++ b/core/sme/src/qos/sme_qos.c @@ -1205,13 +1205,9 @@ static enum sme_qos_statustype sme_qos_internal_setup_req(tpAniSirGlobal pMac, /* we received an expected "good" status */ /* create an entry in the flow list */ pentry = qdf_mem_malloc(sizeof(*pentry)); - if (!pentry) { - QDF_TRACE(QDF_MODULE_ID_SME, - QDF_TRACE_LEVEL_ERROR, - "%s: %d: couldn't allocate memory for the new entry in the Flow List", - __func__, __LINE__); + if (!pentry) return SME_QOS_STATUS_SETUP_FAILURE_RSP; - } + pentry->ac_type = ac; pentry->HDDcontext = HDDcontext; pentry->QoSCallback = QoSCallback; @@ -1553,16 +1549,10 @@ static enum sme_qos_statustype sme_qos_internal_setup_req(tpAniSirGlobal pMac, status)) { /* we received an expected "good" status */ /* create an entry in the flow list */ - pentry = - (struct sme_qos_flowinfoentry *) - qdf_mem_malloc(sizeof(*pentry)); - if (!pentry) { - QDF_TRACE(QDF_MODULE_ID_SME, - QDF_TRACE_LEVEL_ERROR, - "%s: %d: couldn't allocate memory for the new entry in the Flow List", - __func__, __LINE__); + pentry = qdf_mem_malloc(sizeof(*pentry)); + if (!pentry) return SME_QOS_STATUS_SETUP_FAILURE_RSP; - } + pentry->ac_type = ac; pentry->HDDcontext = HDDcontext; pentry->QoSCallback = QoSCallback; @@ -1825,14 +1815,10 @@ static enum sme_qos_statustype sme_qos_internal_modify_req(tpAniSirGlobal pMac, * Flow List Once we have decided on OTA exchange needed or * not we can delete the original one from the List */ - pNewEntry = (struct sme_qos_flowinfoentry *) qdf_mem_malloc( - sizeof(*pNewEntry)); - if (!pNewEntry) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: %d: couldn't allocate memory for the new entry in the Flow List", - __func__, __LINE__); + pNewEntry = qdf_mem_malloc(sizeof(*pNewEntry)); + if (!pNewEntry) return SME_QOS_STATUS_MODIFY_SETUP_FAILURE_RSP; - } + pNewEntry->ac_type = ac; pNewEntry->sessionId = sessionId; pNewEntry->HDDcontext = flow_info->HDDcontext; @@ -3495,14 +3481,9 @@ static QDF_STATUS sme_qos_ft_aggr_qos_req(tpAniSirGlobal mac_ctx, uint8_t session = &sme_qos_cb.sessionInfo[session_id]; - aggr_req = (tSirAggrQosReq *) qdf_mem_malloc(sizeof(tSirAggrQosReq)); - - if (!aggr_req) { - /* err msg */ - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("couldn't allocate memory for the msg buffer")); + aggr_req = qdf_mem_malloc(sizeof(tSirAggrQosReq)); + if (!aggr_req) return QDF_STATUS_E_NOMEM; - } aggr_req->messageType = eWNI_SME_FT_AGGR_QOS_REQ; aggr_req->length = sizeof(tSirAggrQosReq); @@ -3942,14 +3923,10 @@ static QDF_STATUS sme_qos_add_ts_req(tpAniSirGlobal pMac, } pSession = &sme_qos_cb.sessionInfo[sessionId]; - pMsg = (tSirAddtsReq *) qdf_mem_malloc(sizeof(tSirAddtsReq)); - if (!pMsg) { - /* err msg */ - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: %d: couldn't allocate memory for the msg buffer", - __func__, __LINE__); + pMsg = qdf_mem_malloc(sizeof(tSirAddtsReq)); + if (!pMsg) return QDF_STATUS_E_NOMEM; - } + pMsg->messageType = eWNI_SME_ADDTS_REQ; pMsg->length = sizeof(tSirAddtsReq); pMsg->sessionId = sessionId; @@ -4056,14 +4033,10 @@ static QDF_STATUS sme_qos_del_ts_req(tpAniSirGlobal pMac, QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, "%s: %d: invoked on session %d for AC %d", __func__, __LINE__, sessionId, ac); - pMsg = (tSirDeltsReq *) qdf_mem_malloc(sizeof(tSirDeltsReq)); - if (!pMsg) { - /* err msg */ - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: %d: couldn't allocate memory for the msg buffer", - __func__, __LINE__); + pMsg = qdf_mem_malloc(sizeof(tSirDeltsReq)); + if (!pMsg) return QDF_STATUS_E_NOMEM; - } + /* get pointer to the TSPEC being deleted */ pSession = &sme_qos_cb.sessionInfo[sessionId]; pACInfo = &pSession->ac_info[ac]; @@ -6287,15 +6260,10 @@ static QDF_STATUS sme_qos_buffer_cmd(struct sme_qos_cmdinfo *pcmd, QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, "%s: %d: Invoked", __func__, __LINE__); - pentry = (struct sme_qos_cmdinfoentry *) qdf_mem_malloc(sizeof( - struct sme_qos_cmdinfoentry)); - if (!pentry) { - /* err msg */ - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: %d: Memory allocation failure", - __func__, __LINE__); + pentry = qdf_mem_malloc(sizeof(struct sme_qos_cmdinfoentry)); + if (!pentry) return QDF_STATUS_E_NOMEM; - } + /* copy the entire CmdInfo */ pentry->cmdInfo = *pcmd; @@ -6495,13 +6463,10 @@ static QDF_STATUS sme_qos_save_assoc_info(struct sme_qos_sessioninfo *pSession, bssLen = pAssoc_info->pBssDesc->length + sizeof(pAssoc_info->pBssDesc->length); /* save the bss Descriptor */ - pBssDesc = (tSirBssDescription *) qdf_mem_malloc(bssLen); - if (!pBssDesc) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "%s: %d: couldn't allocate memory for the bss Descriptor", - __func__, __LINE__); + pBssDesc = qdf_mem_malloc(bssLen); + if (!pBssDesc) return QDF_STATUS_E_NOMEM; - } + qdf_mem_copy(pBssDesc, pAssoc_info->pBssDesc, bssLen); pSession->assocInfo.pBssDesc = pBssDesc; /* save the apsd info from assoc */ diff --git a/core/sme/src/rrm/sme_rrm.c b/core/sme/src/rrm/sme_rrm.c index 37b766be766e..61be196fef95 100644 --- a/core/sme/src/rrm/sme_rrm.c +++ b/core/sme/src/rrm/sme_rrm.c @@ -185,10 +185,9 @@ sme_rrm_send_beacon_report_xmit_ind(tpAniSirGlobal mac_ctx, do { length = sizeof(tSirBeaconReportXmitInd); beacon_rep = qdf_mem_malloc(length); - if (NULL == beacon_rep) { - sme_err("Unable to allocate memory for beacon report"); + if (!beacon_rep) return QDF_STATUS_E_NOMEM; - } + beacon_rep->messageType = eWNI_SME_BEACON_REPORT_RESP_XMIT_IND; beacon_rep->length = length; beacon_rep->uDialogToken = rrm_ctx->token; @@ -431,12 +430,9 @@ static QDF_STATUS sme_rrm_send_scan_result(tpAniSirGlobal mac_ctx, filter.BSSIDs.bssid = (struct qdf_mac_addr *)&rrm_ctx->bssId; if (rrm_ctx->ssId.length) { - filter.SSIDs.SSIDList = - (tCsrSSIDInfo *) qdf_mem_malloc(sizeof(tCsrSSIDInfo)); - if (filter.SSIDs.SSIDList == NULL) { - sme_err("qdf_mem_malloc failed"); + filter.SSIDs.SSIDList = qdf_mem_malloc(sizeof(tCsrSSIDInfo)); + if (!filter.SSIDs.SSIDList) return QDF_STATUS_E_NOMEM; - } filter.SSIDs.SSIDList->SSID.length = rrm_ctx->ssId.length; @@ -523,14 +519,12 @@ static QDF_STATUS sme_rrm_send_scan_result(tpAniSirGlobal mac_ctx, scanresults_arr = qdf_mem_malloc(num_scan_results * sizeof(next_result)); if (!scanresults_arr) { - sme_err("Failed to allocate scanresults_arr"); status = QDF_STATUS_E_NOMEM; goto rrm_send_scan_results_done; } roam_info = qdf_mem_malloc(sizeof(*roam_info)); - if (NULL == roam_info) { - sme_err("malloc failed"); + if (!roam_info) { status = QDF_STATUS_E_NOMEM; goto rrm_send_scan_results_done; } @@ -760,10 +754,9 @@ static QDF_STATUS sme_rrm_issue_scan_req(tpAniSirGlobal mac_ctx) uint32_t chan_num; req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - sme_debug("Failed to allocate memory"); + if (!req) return QDF_STATUS_E_NOMEM; - } + vdev = wlan_objmgr_get_vdev_by_id_from_psoc( mac_ctx->psoc, session_id, @@ -937,10 +930,9 @@ QDF_STATUS sme_rrm_process_beacon_report_req_ind(tpAniSirGlobal pMac, /* Add all the channel in the regulatory domain. */ wlan_cfg_get_str_len(pMac, WNI_CFG_VALID_CHANNEL_LIST, &len); pSmeRrmContext->channelList.ChannelList = qdf_mem_malloc(len); - if (pSmeRrmContext->channelList.ChannelList == NULL) { - sme_err("qdf_mem_malloc failed"); + if (!pSmeRrmContext->channelList.ChannelList) return QDF_STATUS_E_NOMEM; - } + csr_get_cfg_valid_channels(pMac, pSmeRrmContext->channelList. ChannelList, &len); pSmeRrmContext->channelList.numOfChannels = (uint8_t) len; @@ -958,10 +950,8 @@ QDF_STATUS sme_rrm_process_beacon_report_req_ind(tpAniSirGlobal pMac, len += pBeaconReq->channelList.numChannels; pSmeRrmContext->channelList.ChannelList = qdf_mem_malloc(len); - if (pSmeRrmContext->channelList.ChannelList == NULL) { - sme_err("qdf_mem_malloc failed"); + if (!pSmeRrmContext->channelList.ChannelList) return QDF_STATUS_E_NOMEM; - } if (pBeaconReq->channelInfo.channelNum != 255) { if (csr_roam_is_channel_valid @@ -1056,10 +1046,8 @@ QDF_STATUS sme_rrm_neighbor_report_request(tpAniSirGlobal pMac, uint8_t } pMsg = qdf_mem_malloc(sizeof(tSirNeighborReportReqInd)); - if (NULL == pMsg) { - sme_err("Unable to allocate memory for Neighbor request"); + if (!pMsg) return QDF_STATUS_E_NOMEM; - } rrm_ll_purge_neighbor_cache(pMac, &pMac->rrm.rrmSmeContext.neighborReportCache); @@ -1287,8 +1275,7 @@ static QDF_STATUS sme_rrm_process_neighbor_report(tpAniSirGlobal pMac, for (i = 0; i < pNeighborRpt->numNeighborReports; i++) { pNeighborReportDesc = qdf_mem_malloc(sizeof(tRrmNeighborReportDesc)); - if (NULL == pNeighborReportDesc) { - sme_err("Failed to alloc memory for RRM report desc"); + if (!pNeighborReportDesc) { status = QDF_STATUS_E_NOMEM; goto end; @@ -1296,8 +1283,7 @@ static QDF_STATUS sme_rrm_process_neighbor_report(tpAniSirGlobal pMac, pNeighborReportDesc->pNeighborBssDescription = qdf_mem_malloc(sizeof(tSirNeighborBssDescription)); - if (NULL == pNeighborReportDesc->pNeighborBssDescription) { - sme_err("Failed to alloc mem for RRM BSS Description"); + if (!pNeighborReportDesc->pNeighborBssDescription) { qdf_mem_free(pNeighborReportDesc); status = QDF_STATUS_E_NOMEM; goto end;