From 6768d76a7bf18e5c5904692b4c0391e3cd3bb450 Mon Sep 17 00:00:00 2001 From: Wu Gao Date: Fri, 28 Dec 2018 16:31:08 +0800 Subject: [PATCH] qcacld-3.0: Remove unused tdls structures in pe It alloc memory with structures in sir_api.h, and process/parse them with structures in tdls component, which will cause memory corruption potentially. So, this change refacor these functions and let them use unified structures. Remove unused structures in sir_api.h Here are these functions: - lim_send_sme_tdls_add_sta_rsp - lim_send_tdls_comp_mgmt_rsp - lim_send_sme_tdls_del_sta_rsp - lim_send_sme_mgmt_tx_completion Remove below unused tdls structures: - tSirTdlsDelAllPeerInd - tSirTdlsDelStaInd - tSirTdlsEventnotify - tSirTdlsLinkEstablishReq - tSirTdlsLinkEstablishReqRsp - tSirTdlsAddStaRsp - tSirTdlsDelStaRsp - tSirMgmtTxCompletionInd Change-Id: Ic595cadefcdbeb2df44f97563c4652db409213a2 CRs-Fixed: 2373706 --- .../tdls/core/src/wlan_tdls_cmds_process.h | 95 +-------------- .../dispatcher/inc/wlan_tdls_public_structs.h | 79 ++++++++++++- core/mac/inc/sir_api.h | 82 ------------- core/mac/src/pe/lim/lim_process_tdls.c | 109 ++++++++++-------- .../src/pe/lim/lim_send_sme_rsp_messages.c | 40 +++---- 5 files changed, 160 insertions(+), 245 deletions(-) diff --git a/components/tdls/core/src/wlan_tdls_cmds_process.h b/components/tdls/core/src/wlan_tdls_cmds_process.h index e66b41aa69..56a06164f9 100644 --- a/components/tdls/core/src/wlan_tdls_cmds_process.h +++ b/components/tdls/core/src/wlan_tdls_cmds_process.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019 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 @@ -29,53 +29,6 @@ ((TDLS_SETUP_REQUEST <= action) && \ (TDLS_SETUP_CONFIRM >= action)) -/** - * enum legacy_result_code - defined to comply with tSirResultCodes, need refine - * when mlme converged. - * @legacy_result_success: success - * @legacy_result_max: max result value - */ -enum legacy_result_code { - legacy_result_success, - legacy_result_max = 0x7FFFFFFF -}; - -/** - * struct tdls_send_mgmt_rsp - TDLS Response struct PE --> TDLS module - * same as struct tSirSmeRsp - * @message_type: message type eWNI_SME_TDLS_SEND_MGMT_RSP - * @length: message length - * @session_id: session id - * @transaction_id: transaction id - * @status_code: status code as tSirResultCodes - * @psoc: soc object - */ -struct tdls_send_mgmt_rsp { - uint16_t message_type; - uint16_t length; - uint8_t session_id; - uint16_t transaction_id; - enum legacy_result_code status_code; - struct wlan_objmgr_psoc *psoc; -}; - -/** - * struct tdls_mgmt_tx_completion_ind - TDLS TX completion PE --> TDLS module - * same as struct sSirMgmtTxCompletionInd - * @message_type: message type eWNI_SME_MGMT_FRM_TX_COMPLETION_IND - * @length: message length - * @session_id: session id - * @tx_complete_status: tx complete status - * @psoc: soc object - */ -struct tdls_mgmt_tx_completion_ind { - uint16_t message_type; - uint16_t length; - uint8_t session_id; /* Session ID */ - uint32_t tx_complete_status; - struct wlan_objmgr_psoc *psoc; -}; - /** * struct tdls_add_sta_req - TDLS request struct TDLS module --> PE * same as struct tSirTdlsAddStaReq; @@ -117,31 +70,6 @@ struct tdls_add_sta_req { uint8_t max_sp; }; -/** - * struct tdls_add_sta_rsp - TDLS Response struct PE --> TDLS module - * same as struct sSirTdlsAddStaRsp - * @message_type: message type eWNI_SME_TDLS_ADD_STA_RSP - * @length: message length - * @status_code: status code as tSirResultCodes - * @peermac: MAC address of the TDLS peer - * @session_id: session id - * @sta_id: sta id - * @sta_type: sta type - * @tdls_oper: add peer type - * @psoc: soc object - */ -struct tdls_add_sta_rsp { - uint16_t message_type; - uint16_t length; - QDF_STATUS status_code; - struct qdf_mac_addr peermac; - uint8_t session_id; - uint16_t sta_id; - uint16_t sta_type; - enum tdls_add_oper tdls_oper; - struct wlan_objmgr_psoc *psoc; -}; - /** * struct tdls_del_sta_req - TDLS Request struct TDLS module --> PE * same as sSirTdlsDelStaReq @@ -161,27 +89,6 @@ struct tdls_del_sta_req { struct qdf_mac_addr peermac; }; -/** - * struct tdls_del_sta_rsp - TDLS Response struct PE --> TDLS module - * same as sSirTdlsDelStaRsp - * @message_type: message type eWNI_SME_TDLS_DEL_STA_RSP - * @length: message length - * @session_id: session id - * @status_code: status code as tSirResultCodes - * @peermac: MAC address of the TDLS peer - * @sta_id: sta id - * @psoc: soc object - */ -struct tdls_del_sta_rsp { - uint16_t message_type; - uint16_t length; - uint8_t session_id; - QDF_STATUS status_code; - struct qdf_mac_addr peermac; - uint16_t sta_id; - struct wlan_objmgr_psoc *psoc; -}; - /** * tdls_process_add_peer() - add TDLS peer * @req: TDLS add peer request diff --git a/components/tdls/dispatcher/inc/wlan_tdls_public_structs.h b/components/tdls/dispatcher/inc/wlan_tdls_public_structs.h index 212895974e..deae17e81c 100644 --- a/components/tdls/dispatcher/inc/wlan_tdls_public_structs.h +++ b/components/tdls/dispatcher/inc/wlan_tdls_public_structs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019 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 @@ -1167,4 +1167,81 @@ struct tdls_set_secoffchanneloffset { tdls_offchan_parms_callback callback; }; +/** + * enum legacy_result_code - defined to comply with tSirResultCodes, need refine + * when mlme converged. + * @legacy_result_success: success + * @legacy_result_max: max result value + */ +enum legacy_result_code { + legacy_result_success, + legacy_result_max = 0x7FFFFFFF +}; + +/** + * struct tdls_send_mgmt_rsp - TDLS Response struct PE --> TDLS module + * same as struct tSirSmeRsp + * @session_id: session id + * @transaction_id: transaction id + * @status_code: status code as tSirResultCodes + * @psoc: soc object + */ +struct tdls_send_mgmt_rsp { + uint8_t session_id; + uint16_t transaction_id; + enum legacy_result_code status_code; + struct wlan_objmgr_psoc *psoc; +}; + +/** + * struct tdls_mgmt_tx_completion_ind - TDLS TX completion PE --> TDLS module + * same as struct sSirMgmtTxCompletionInd + * @session_id: session id + * @tx_complete_status: tx complete status + * @psoc: soc object + */ +struct tdls_mgmt_tx_completion_ind { + uint8_t session_id; /* Session ID */ + uint32_t tx_complete_status; + struct wlan_objmgr_psoc *psoc; +}; + +/** + * struct tdls_add_sta_rsp - TDLS Response struct PE --> TDLS module + * same as struct sSirTdlsAddStaRsp + * @status_code: status code as tSirResultCodes + * @peermac: MAC address of the TDLS peer + * @session_id: session id + * @sta_id: sta id + * @sta_type: sta type + * @tdls_oper: add peer type + * @psoc: soc object + */ +struct tdls_add_sta_rsp { + QDF_STATUS status_code; + struct qdf_mac_addr peermac; + uint8_t session_id; + uint16_t sta_id; + uint16_t sta_type; + enum tdls_add_oper tdls_oper; + struct wlan_objmgr_psoc *psoc; +}; + +/** + * struct tdls_del_sta_rsp - TDLS Response struct PE --> TDLS module + * same as sSirTdlsDelStaRsp + * @session_id: session id + * @status_code: status code as tSirResultCodes + * @peermac: MAC address of the TDLS peer + * @sta_id: sta id + * @psoc: soc object + */ +struct tdls_del_sta_rsp { + uint8_t session_id; + QDF_STATUS status_code; + struct qdf_mac_addr peermac; + uint16_t sta_id; + struct wlan_objmgr_psoc *psoc; +}; + #endif diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index 172f2d3a5f..3d90f69d5f 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -2597,50 +2597,6 @@ typedef struct sSirTdlsAddStaReq { uint8_t max_sp; } tSirTdlsAddStaReq, *tpSirSmeTdlsAddStaReq; -/* TDLS Response struct PE-->SME */ -typedef struct sSirTdlsAddStaRsp { - uint16_t messageType; - uint16_t length; - tSirResultCodes statusCode; - struct qdf_mac_addr peermac; - uint8_t sessionId; /* Session ID */ - uint16_t staId; - uint16_t staType; - enum tdls_add_oper tdlsAddOper; - struct wlan_objmgr_psoc *psoc; -} tSirTdlsAddStaRsp; - -/* TDLS Request struct SME-->PE */ -typedef struct { - uint16_t messageType; /* eWNI_SME_TDLS_LINK_ESTABLISH_REQ */ - uint16_t length; - uint8_t sessionId; /* Session ID */ - uint16_t transactionId; /* Transaction ID for cmd */ - uint8_t uapsdQueues; /* Peer's uapsd Queues Information */ - uint8_t maxSp; /* Peer's Supported Maximum Service Period */ - uint8_t isBufSta; /* Does Peer Support as Buffer Station. */ - /* Does Peer Support as TDLS Off Channel. */ - uint8_t isOffChannelSupported; - uint8_t isResponder; /* Is Peer a responder. */ - /* For multi-session, for PE to locate peSession ID */ - struct qdf_mac_addr bssid; - struct qdf_mac_addr peermac; - uint8_t supportedChannelsLen; - uint8_t supportedChannels[SIR_MAC_MAX_SUPP_CHANNELS]; - uint8_t supportedOperClassesLen; - uint8_t supportedOperClasses[REG_MAX_SUPP_OPER_CLASSES]; -} tSirTdlsLinkEstablishReq, *tpSirTdlsLinkEstablishReq; - -/* TDLS Request struct SME-->PE */ -typedef struct { - uint16_t messageType; /* eWNI_SME_TDLS_LINK_ESTABLISH_RSP */ - uint16_t length; - uint8_t sessionId; /* Session ID */ - uint16_t transactionId; /* Transaction ID for cmd */ - tSirResultCodes statusCode; - struct qdf_mac_addr peermac; -} tSirTdlsLinkEstablishReqRsp, *tpSirTdlsLinkEstablishReqRsp; - /* TDLS Request struct SME-->PE */ typedef struct sSirTdlsDelStaReq { uint16_t messageType; /* eWNI_SME_TDLS_DISCOVERY_START_REQ */ @@ -2651,44 +2607,6 @@ typedef struct sSirTdlsDelStaReq { struct qdf_mac_addr bssid; struct qdf_mac_addr peermac; } tSirTdlsDelStaReq, *tpSirSmeTdlsDelStaReq; -/* TDLS Response struct PE-->SME */ -typedef struct sSirTdlsDelStaRsp { - uint16_t messageType; - uint16_t length; - uint8_t sessionId; /* Session ID */ - tSirResultCodes statusCode; - struct qdf_mac_addr peermac; - uint16_t staId; - struct wlan_objmgr_psoc *psoc; -} tSirTdlsDelStaRsp, *tpSirTdlsDelStaRsp; -/* TDLS Delete Indication struct PE-->SME */ -typedef struct sSirTdlsDelStaInd { - uint16_t messageType; - uint16_t length; - uint8_t sessionId; /* Session ID */ - struct qdf_mac_addr peermac; - uint16_t staId; - uint16_t reasonCode; -} tSirTdlsDelStaInd, *tpSirTdlsDelStaInd; -typedef struct sSirTdlsDelAllPeerInd { - uint16_t messageType; - uint16_t length; - uint8_t sessionId; /* Session ID */ -} tSirTdlsDelAllPeerInd, *tpSirTdlsDelAllPeerInd; -typedef struct sSirMgmtTxCompletionInd { - uint16_t messageType; - uint16_t length; - uint8_t sessionId; /* Session ID */ - uint32_t txCompleteStatus; - struct wlan_objmgr_psoc *psoc; -} tSirMgmtTxCompletionInd, *tpSirMgmtTxCompletionInd; - -typedef struct sSirTdlsEventnotify { - uint8_t sessionId; - struct qdf_mac_addr peermac; - uint16_t messageType; - uint32_t peer_reason; -} tSirTdlsEventnotify; #endif /* FEATURE_WLAN_TDLS */ /* Reset AP Caps Changed */ diff --git a/core/mac/src/pe/lim/lim_process_tdls.c b/core/mac/src/pe/lim/lim_process_tdls.c index 93aafb0c49..8a2d4d6e18 100644 --- a/core/mac/src/pe/lim/lim_process_tdls.c +++ b/core/mac/src/pe/lim/lim_process_tdls.c @@ -73,6 +73,7 @@ #include "wlan_tdls_tgt_api.h" #include "wlan_mlme_public_struct.h" #include "wlan_mlme_api.h" +#include "wlan_tdls_public_structs.h" /* define NO_PAD_TDLS_MIN_8023_SIZE to NOT padding: See CR#447630 There was IOT issue with cisco 1252 open mode, where it pads @@ -2677,38 +2678,43 @@ static QDF_STATUS lim_send_sme_tdls_add_sta_rsp(struct mac_context *mac, uint8_t updateSta, tDphHashNode *pStaDs, uint8_t status) { - struct scheduler_msg mmhMsg = { 0 }; - tSirTdlsAddStaRsp *addStaRsp = NULL; + struct scheduler_msg msg = { 0 }; + struct tdls_add_sta_rsp *add_sta_rsp; + QDF_STATUS ret; - mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP; + msg.type = eWNI_SME_TDLS_ADD_STA_RSP; - addStaRsp = qdf_mem_malloc(sizeof(tSirTdlsAddStaRsp)); - if (!addStaRsp) + add_sta_rsp = qdf_mem_malloc(sizeof(*add_sta_rsp)); + if (!add_sta_rsp) return QDF_STATUS_E_NOMEM; - addStaRsp->sessionId = sessionId; - addStaRsp->statusCode = status; + add_sta_rsp->session_id = sessionId; + add_sta_rsp->status_code = status; if (pStaDs) { - addStaRsp->staId = pStaDs->staIndex; + add_sta_rsp->sta_id = pStaDs->staIndex; } if (peerMac) { - qdf_mem_copy(addStaRsp->peermac.bytes, + qdf_mem_copy(add_sta_rsp->peermac.bytes, (uint8_t *) peerMac, QDF_MAC_ADDR_SIZE); } if (updateSta) - addStaRsp->tdlsAddOper = TDLS_OPER_UPDATE; + add_sta_rsp->tdls_oper = TDLS_OPER_UPDATE; else - addStaRsp->tdlsAddOper = TDLS_OPER_ADD; + add_sta_rsp->tdls_oper = TDLS_OPER_ADD; - addStaRsp->length = sizeof(tSirTdlsAddStaRsp); - addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP; - addStaRsp->psoc = mac->psoc; - mmhMsg.bodyptr = addStaRsp; - mmhMsg.callback = tgt_tdls_add_peer_rsp; + add_sta_rsp->psoc = mac->psoc; + msg.bodyptr = add_sta_rsp; + msg.callback = tgt_tdls_add_peer_rsp; - return scheduler_post_message(QDF_MODULE_ID_PE, - QDF_MODULE_ID_TDLS, - QDF_MODULE_ID_TARGET_IF, &mmhMsg); + ret = scheduler_post_message(QDF_MODULE_ID_PE, + QDF_MODULE_ID_TDLS, + QDF_MODULE_ID_TARGET_IF, &msg); + if (QDF_IS_STATUS_ERROR(ret)) { + pe_err("post msg fail, %d", ret); + qdf_mem_free(add_sta_rsp); + } + + return ret; } /* @@ -2776,30 +2782,32 @@ lim_send_tdls_comp_mgmt_rsp(struct mac_context *mac_ctx, uint16_t msg_type, uint16_t sme_transaction_id) { struct scheduler_msg msg = {0}; - tSirSmeRsp *sme_rsp; + struct tdls_send_mgmt_rsp *sme_rsp; + QDF_STATUS status; pe_debug("Sending message %s with reasonCode %s", lim_msg_str(msg_type), lim_result_code_str(result_code)); - sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp)); + sme_rsp = qdf_mem_malloc(sizeof(*sme_rsp)); if (!sme_rsp) return; - sme_rsp->messageType = msg_type; - sme_rsp->length = sizeof(tSirSmeRsp); - sme_rsp->statusCode = result_code; + sme_rsp->status_code = (enum legacy_result_code)result_code; - sme_rsp->sessionId = sme_session_id; - sme_rsp->transactionId = sme_transaction_id; + sme_rsp->session_id = sme_session_id; + sme_rsp->transaction_id = sme_transaction_id; msg.type = msg_type; sme_rsp->psoc = mac_ctx->psoc; msg.bodyptr = sme_rsp; msg.callback = tgt_tdls_send_mgmt_rsp; - scheduler_post_message(QDF_MODULE_ID_PE, - QDF_MODULE_ID_TDLS, - QDF_MODULE_ID_TARGET_IF, &msg); - + status = scheduler_post_message(QDF_MODULE_ID_PE, + QDF_MODULE_ID_TDLS, + QDF_MODULE_ID_TARGET_IF, &msg); + if (QDF_IS_STATUS_ERROR(status)) { + pe_err("post msg fail, %d", status); + qdf_mem_free(sme_rsp); + } } /** @@ -2942,32 +2950,37 @@ static QDF_STATUS lim_send_sme_tdls_del_sta_rsp(struct mac_context *mac, struct qdf_mac_addr peerMac, tDphHashNode *pStaDs, uint8_t status) { - struct scheduler_msg mmhMsg = { 0 }; - tSirTdlsDelStaRsp *pDelSta = NULL; + struct scheduler_msg msg = { 0 }; + struct tdls_del_sta_rsp *del_sta_rsp; + QDF_STATUS ret; - mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP; + msg.type = eWNI_SME_TDLS_DEL_STA_RSP; - pDelSta = qdf_mem_malloc(sizeof(tSirTdlsDelStaRsp)); - if (!pDelSta) + del_sta_rsp = qdf_mem_malloc(sizeof(*del_sta_rsp)); + if (!del_sta_rsp) return QDF_STATUS_E_NOMEM; - pDelSta->sessionId = sessionId; - pDelSta->statusCode = status; + del_sta_rsp->session_id = sessionId; + del_sta_rsp->status_code = status; if (pStaDs) { - pDelSta->staId = pStaDs->staIndex; + del_sta_rsp->sta_id = pStaDs->staIndex; } else - pDelSta->staId = STA_INVALID_IDX; + del_sta_rsp->sta_id = STA_INVALID_IDX; - qdf_copy_macaddr(&pDelSta->peermac, &peerMac); + qdf_copy_macaddr(&del_sta_rsp->peermac, &peerMac); - pDelSta->length = sizeof(tSirTdlsDelStaRsp); - pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP; - pDelSta->psoc = mac->psoc; - mmhMsg.bodyptr = pDelSta; - mmhMsg.callback = tgt_tdls_del_peer_rsp; - return scheduler_post_message(QDF_MODULE_ID_PE, - QDF_MODULE_ID_TDLS, - QDF_MODULE_ID_TARGET_IF, &mmhMsg); + del_sta_rsp->psoc = mac->psoc; + msg.bodyptr = del_sta_rsp; + msg.callback = tgt_tdls_del_peer_rsp; + ret = scheduler_post_message(QDF_MODULE_ID_PE, + QDF_MODULE_ID_TDLS, + QDF_MODULE_ID_TARGET_IF, &msg); + if (QDF_IS_STATUS_ERROR(ret)) { + pe_err("post msg fail, %d", ret); + qdf_mem_free(del_sta_rsp); + } + + return ret; } /* diff --git a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c index afc269af27..4014aef2d9 100644 --- a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c +++ b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2019 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 @@ -1075,33 +1075,33 @@ lim_send_sme_mgmt_tx_completion(struct mac_context *mac, uint32_t sme_session_id, uint32_t txCompleteStatus) { - struct scheduler_msg mmhMsg = {0}; - tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd; + struct scheduler_msg msg = {0}; + struct tdls_mgmt_tx_completion_ind *mgmt_tx_completion_ind; + QDF_STATUS status; - pSirMgmtTxCompletionInd = - qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd)); - if (!pSirMgmtTxCompletionInd) + mgmt_tx_completion_ind = + qdf_mem_malloc(sizeof(*mgmt_tx_completion_ind)); + if (!mgmt_tx_completion_ind) return; - /* messageType */ - pSirMgmtTxCompletionInd->messageType = - eWNI_SME_MGMT_FRM_TX_COMPLETION_IND; - pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd); /* sessionId */ - pSirMgmtTxCompletionInd->sessionId = sme_session_id; + mgmt_tx_completion_ind->session_id = sme_session_id; - pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus; + mgmt_tx_completion_ind->tx_complete_status = txCompleteStatus; - mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND; - mmhMsg.bodyptr = pSirMgmtTxCompletionInd; - mmhMsg.bodyval = 0; + msg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND; + msg.bodyptr = mgmt_tx_completion_ind; + msg.bodyval = 0; - pSirMgmtTxCompletionInd->psoc = mac->psoc; - mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion; - scheduler_post_message(QDF_MODULE_ID_PE, + mgmt_tx_completion_ind->psoc = mac->psoc; + msg.callback = tgt_tdls_send_mgmt_tx_completion; + status = scheduler_post_message(QDF_MODULE_ID_PE, QDF_MODULE_ID_TDLS, - QDF_MODULE_ID_TARGET_IF, &mmhMsg); - return; + QDF_MODULE_ID_TARGET_IF, &msg); + if (QDF_IS_STATUS_ERROR(status)) { + pe_err("post msg fail, %d", status); + qdf_mem_free(mgmt_tx_completion_ind); + } } /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/ #endif /* FEATURE_WLAN_TDLS */