diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 687ff0bc63..a530c45949 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -4497,6 +4497,13 @@ int hdd_vdev_create(struct hdd_adapter *adapter) /* do vdev create via objmgr */ hdd_ctx = WLAN_HDD_GET_CTX(adapter); + status = sme_check_for_duplicate_session(hdd_ctx->mac_handle, + adapter->mac_addr.bytes); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Duplicate session is existing with same mac address"); + errno = qdf_status_to_os_return(status); + return errno; + } errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); if (errno) { hdd_err("failed to create objmgr vdev: %d", errno); diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 12c7ca7a98..3f190856b3 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -3941,4 +3941,16 @@ uint16_t sme_get_full_roam_scan_period_global(mac_handle_t mac_handle); QDF_STATUS sme_get_full_roam_scan_period(mac_handle_t mac_handle, uint8_t vdev_id, uint32_t *full_roam_scan_period); + +/** + * sme_check_for_duplicate_session() - check for duplicate session + * @mac_handle: Opaque handle to the MAC context + * @peer_addr: Peer device mac address + * + * Check for duplicate mac address is available on other vdev. + * + * Return: QDF_STATUS + */ +QDF_STATUS sme_check_for_duplicate_session(mac_handle_t mac_handle, + uint8_t *peer_addr); #endif /* #if !defined( __SME_API_H ) */ diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 4cba470c81..7a12549fee 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -4504,10 +4504,7 @@ QDF_STATUS sme_create_vdev(mac_handle_t mac_handle, { QDF_STATUS status = QDF_STATUS_E_INVAL; struct mac_context *mac_ctx = MAC_CONTEXT(mac_handle); - struct cdp_pdev *pdev; - ol_txrx_peer_handle peer; - u8 peer_id, vdev_id; - void *soc = cds_get_context(QDF_MODULE_ID_SOC); + uint8_t vdev_id; u8 *mac_addr; vdev_id = wlan_vdev_get_id(params->vdev); @@ -4515,28 +4512,13 @@ QDF_STATUS sme_create_vdev(mac_handle_t mac_handle, sme_debug("vdev_id %d addr:%pM", vdev_id, mac_addr); - pdev = cds_get_context(QDF_MODULE_ID_TXRX); - - if (!pdev) { - sme_err("Failed to get pdev handler"); - return status; - } - status = sme_acquire_global_lock(&mac_ctx->sme); if (QDF_IS_STATUS_ERROR(status)) return status; - peer = cdp_peer_find_by_addr(soc, pdev, - mac_addr, - &peer_id); - if (peer) { - sme_err("Peer=%d exist with same MAC", peer_id); - status = QDF_STATUS_E_INVAL; - } else { - status = csr_create_vdev(mac_ctx, params->vdev, params); - if (QDF_IS_STATUS_SUCCESS(status)) - status = mlme_vdev_self_peer_create(params->vdev); - } + status = csr_create_vdev(mac_ctx, params->vdev, params); + if (QDF_IS_STATUS_SUCCESS(status)) + status = mlme_vdev_self_peer_create(params->vdev); sme_release_global_lock(&mac_ctx->sme); MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION, @@ -16188,3 +16170,41 @@ sme_get_full_roam_scan_period(mac_handle_t mac_handle, uint8_t vdev_id, return status; } + +QDF_STATUS sme_check_for_duplicate_session(mac_handle_t mac_handle, + uint8_t *peer_addr) +{ + QDF_STATUS status = QDF_STATUS_E_INVAL; + struct cdp_pdev *pdev; + ol_txrx_peer_handle peer; + uint8_t peer_id; + void *soc = cds_get_context(QDF_MODULE_ID_SOC); + struct mac_context *mac_ctx = MAC_CONTEXT(mac_handle); + + if (!soc) { + sme_err("Failed to get soc handle"); + return QDF_STATUS_E_INVAL; + } + + pdev = cds_get_context(QDF_MODULE_ID_TXRX); + if (!pdev) { + sme_err("Failed to get pdev handler"); + return QDF_STATUS_E_INVAL; + } + + if (QDF_STATUS_SUCCESS != sme_acquire_global_lock(&mac_ctx->sme)) + return status; + + peer = cdp_peer_find_by_addr(soc, pdev, + peer_addr, + &peer_id); + if (peer) { + sme_err("Peer=%d exist with same MAC", peer_id); + status = QDF_STATUS_E_EXISTS; + } else { + status = QDF_STATUS_SUCCESS; + } + sme_release_global_lock(&mac_ctx->sme); + + return status; +}