From 1c678483863d392bac8550639e1db07ceb59e7fe Mon Sep 17 00:00:00 2001 From: Lin Bai Date: Mon, 18 Dec 2017 18:29:11 +0800 Subject: [PATCH] qcacld-3.0: Fix FTM mode malfunction and memory leak Current driver will create two apdaters in FTM mode, with device_mode STA and P2P, where STA is incorrect and P2P is unnecessary. And those types will cause memory leak in qdf_mem_malloc()/sme_deregister_mgmt_frame(), when unloading driver. Also, it is improper to fix the interface name to wlan0 for FTM mode, as some platforms may use different naming rule. Only create one adapter with FTM mode, with variable interface name. CRs-Fixed: 2160513 Change-Id: If3bf4444e5535e6fe88c3ad2d87da217534984a0 --- core/hdd/src/wlan_hdd_main.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index a13890802298..305d51f9a164 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -2102,6 +2102,8 @@ int hdd_start_adapter(struct hdd_adapter *adapter) ret = hdd_start_ftm_adapter(adapter); if (ret) goto err_start_adapter; + else + goto ftm_complete; break; default: hdd_err("Invalid session type %d", device_mode); @@ -2121,6 +2123,7 @@ int hdd_start_adapter(struct hdd_adapter *adapter) goto err_start_adapter; } +ftm_complete: EXIT(); return 0; err_start_adapter: @@ -4337,7 +4340,7 @@ struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx, uint8_t sessio case QDF_FTM_MODE: adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, name_assign_type, - "wlan0"); + iface_name); if (NULL == adapter) { hdd_err("Failed to allocate adapter for FTM mode"); return NULL; @@ -8422,14 +8425,19 @@ static int hdd_open_interfaces(struct hdd_context *hdd_ctx, bool rtnl_held) int ret; /* open monitor mode adapter if con_mode is monitor mode */ - if (con_mode == QDF_GLOBAL_MONITOR_MODE) { - adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", - wlan_hdd_get_intf_addr(hdd_ctx), - NET_NAME_UNKNOWN, rtnl_held); + if (con_mode == QDF_GLOBAL_MONITOR_MODE || + con_mode == QDF_GLOBAL_FTM_MODE) { + uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? + QDF_MONITOR_MODE : QDF_FTM_MODE; + + adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", + wlan_hdd_get_intf_addr(hdd_ctx), + NET_NAME_UNKNOWN, rtnl_held); if (!adapter) { hdd_err("open adapter failed"); return -ENOSPC; } + return 0; }