From 045aea075ce33857dd0a5ff453cfe99c8622334b Mon Sep 17 00:00:00 2001 From: Li Feng Date: Sun, 12 Apr 2020 21:35:42 +0800 Subject: [PATCH] qcacld-3.0: Release intf addr if failed to open adapter Release intf addr which is allocated by wlan_hdd_get_intf_addr() to clean up dynamic mac list if failed to open adapter. Change-Id: I3649719496b4f69ce92801d87c05f6af438e5479 CRs-Fixed: 2662240 --- core/hdd/src/wlan_hdd_main.c | 50 ++++++++++++++++++++++------ core/hdd/src/wlan_hdd_nan_datapath.c | 2 ++ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 01cba6cd727f..ef354dea9476 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -13133,6 +13133,9 @@ static QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) "p2p%d", hdd_ctx->p2p_device_address.bytes); if (QDF_IS_STATUS_ERROR(status)) { + if (!is_p2p_locally_administered) + wlan_hdd_release_intf_addr(hdd_ctx, + hdd_ctx->p2p_device_address.bytes); hdd_err("Failed to open p2p interface"); return QDF_STATUS_E_INVAL; } @@ -13154,8 +13157,10 @@ static QDF_STATUS hdd_open_ocb_interface(struct hdd_context *hdd_ctx) mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_OCB_MODE); status = hdd_open_adapter_no_trans(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", mac_addr); - if (QDF_IS_STATUS_ERROR(status)) + if (QDF_IS_STATUS_ERROR(status)) { + wlan_hdd_release_intf_addr(hdd_ctx, mac_addr); hdd_err("Failed to open 802.11p interface"); + } return status; } @@ -13173,8 +13178,10 @@ static QDF_STATUS hdd_open_concurrent_interface(struct hdd_context *hdd_ctx) mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, iface_name, mac_addr); - if (QDF_IS_STATUS_ERROR(status)) + if (QDF_IS_STATUS_ERROR(status)) { + wlan_hdd_release_intf_addr(hdd_ctx, mac_addr); hdd_err("Failed to open concurrent station interface"); + } return status; } @@ -13195,8 +13202,10 @@ hdd_open_adapters_for_mission_mode(struct hdd_context *hdd_ctx) mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, "wlan%d", mac_addr); - if (QDF_IS_STATUS_ERROR(status)) + if (QDF_IS_STATUS_ERROR(status)) { + wlan_hdd_release_intf_addr(hdd_ctx, mac_addr); return status; + } /* opening concurrent STA is best effort, continue on error */ hdd_open_concurrent_interface(hdd_ctx); @@ -13214,8 +13223,10 @@ hdd_open_adapters_for_mission_mode(struct hdd_context *hdd_ctx) mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_NAN_DISC_MODE); status = hdd_open_adapter_no_trans(hdd_ctx, QDF_NAN_DISC_MODE, "wifi-aware%d", mac_addr); - if (status) + if (status) { + wlan_hdd_release_intf_addr(hdd_ctx, mac_addr); goto err_close_adapters; + } } /* Open 802.11p Interface */ if (dot11p_mode == CFG_11P_CONCURRENT) { @@ -13234,19 +13245,38 @@ err_close_adapters: static QDF_STATUS hdd_open_adapters_for_ftm_mode(struct hdd_context *hdd_ctx) { - uint8_t *mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_FTM_MODE); + QDF_STATUS status; + uint8_t *mac_addr; - return hdd_open_adapter_no_trans(hdd_ctx, QDF_FTM_MODE, - "wlan%d", mac_addr); + mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_FTM_MODE); + status = hdd_open_adapter_no_trans(hdd_ctx, QDF_FTM_MODE, + "wlan%d", mac_addr); + + if (QDF_IS_STATUS_ERROR(status)) { + wlan_hdd_release_intf_addr(hdd_ctx, mac_addr); + return status; + } + + return QDF_STATUS_SUCCESS; } static QDF_STATUS hdd_open_adapters_for_monitor_mode(struct hdd_context *hdd_ctx) { - uint8_t *mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_MONITOR_MODE); + QDF_STATUS status; + uint8_t *mac_addr; - return hdd_open_adapter_no_trans(hdd_ctx, QDF_MONITOR_MODE, - "wlan%d", mac_addr); + mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_MONITOR_MODE); + + status = hdd_open_adapter_no_trans(hdd_ctx, QDF_MONITOR_MODE, + "wlan%d", mac_addr); + + if (QDF_IS_STATUS_ERROR(status)) { + wlan_hdd_release_intf_addr(hdd_ctx, mac_addr); + return status; + } + + return QDF_STATUS_SUCCESS; } static QDF_STATUS hdd_open_adapters_for_epping_mode(struct hdd_context *hdd_ctx) diff --git a/core/hdd/src/wlan_hdd_nan_datapath.c b/core/hdd/src/wlan_hdd_nan_datapath.c index 9d5d0cd4d495..6b5b7dcb4a99 100644 --- a/core/hdd/src/wlan_hdd_nan_datapath.c +++ b/core/hdd/src/wlan_hdd_nan_datapath.c @@ -582,6 +582,8 @@ int hdd_ndi_open(char *iface_name) adapter = hdd_open_adapter(hdd_ctx, QDF_NDI_MODE, iface_name, ndi_mac_addr, NET_NAME_UNKNOWN, true); if (!adapter) { + if (!cfg_nan_get_ndi_mac_randomize(hdd_ctx->psoc)) + wlan_hdd_release_intf_addr(hdd_ctx, ndi_mac_addr); hdd_err("hdd_open_adapter failed"); return -EINVAL; }