qcacld-3.0: Fix Memory leak sta_ap_intf_check_work_info

At present policy_mgr_check_concurrent_intf_and_restart_sap
will allocate memory for sta_ap_intf_check_work_info for each
work scheduling of sta_ap_intf_check_work. Potential race condition
would be the pm_ctx->sta_ap_intf_check_work_info is overwritten
in other thread context which is calling same function.
It is not necessary to maintain the memory
sta_ap_intf_check_work_info dynamically since only one work
sta_ap_intf_check_work is expected to run at same time.

Move the sta_ap_intf_check_work_info memory allocation to
psoc open handler and free it when psoc close.

Change-Id: I29b2f2528a6d537cb853968153340a75fd5fe88b
CRs-Fixed: 2571624
This commit is contained in:
Liangwei Dong 2019-11-25 15:50:28 +08:00 committed by nshrivas
parent 1b3b9c352d
commit b5e89852ab
2 changed files with 18 additions and 16 deletions

View File

@ -1821,11 +1821,6 @@ static void __policy_mgr_check_sta_ap_concurrent_ch_intf(void *data)
end:
pm_ctx->do_sap_unsafe_ch_check = false;
if (work_info) {
qdf_mem_free(work_info);
if (pm_ctx)
pm_ctx->sta_ap_intf_check_work_info = NULL;
}
}
void policy_mgr_check_sta_ap_concurrent_ch_intf(void *data)
@ -1991,6 +1986,10 @@ void policy_mgr_check_concurrent_intf_and_restart_sap(
policy_mgr_err("Invalid context");
return;
}
if (!pm_ctx->sta_ap_intf_check_work_info) {
policy_mgr_err("Invalid sta_ap_intf_check_work_info");
return;
}
/*
* If STA+SAP sessions are on DFS channel and STA+SAP SCC is
* enabled on DFS channel then move the SAP out of DFS channel
@ -2041,17 +2040,8 @@ sap_restart:
*/
if (restart_sap ||
((mcc_to_scc_switch != QDF_MCC_TO_SCC_SWITCH_DISABLE) &&
policy_mgr_valid_sta_channel_check(psoc, op_ch_freq_list[0]) &&
!pm_ctx->sta_ap_intf_check_work_info)) {
struct sta_ap_intf_check_work_ctx *work_info;
work_info = qdf_mem_malloc(
sizeof(struct sta_ap_intf_check_work_ctx));
pm_ctx->sta_ap_intf_check_work_info = work_info;
if (work_info) {
work_info->psoc = psoc;
qdf_create_work(0, &pm_ctx->sta_ap_intf_check_work,
policy_mgr_check_sta_ap_concurrent_ch_intf,
work_info);
policy_mgr_valid_sta_channel_check(psoc, op_ch_freq_list[0]))) {
if (pm_ctx->sta_ap_intf_check_work_info) {
qdf_sched_work(0, &pm_ctx->sta_ap_intf_check_work);
policy_mgr_info(
"Checking for Concurrent Change interference");

View File

@ -331,6 +331,18 @@ QDF_STATUS policy_mgr_psoc_open(struct wlan_objmgr_psoc *psoc)
return QDF_STATUS_E_FAILURE;
}
pm_ctx->sta_ap_intf_check_work_info = qdf_mem_malloc(
sizeof(struct sta_ap_intf_check_work_ctx));
if (!pm_ctx->sta_ap_intf_check_work_info) {
qdf_mutex_destroy(&pm_ctx->qdf_conc_list_lock);
policy_mgr_err("Failed to alloc sta_ap_intf_check_work_info");
return QDF_STATUS_E_FAILURE;
}
pm_ctx->sta_ap_intf_check_work_info->psoc = psoc;
qdf_create_work(0, &pm_ctx->sta_ap_intf_check_work,
policy_mgr_check_sta_ap_concurrent_ch_intf,
pm_ctx->sta_ap_intf_check_work_info);
return QDF_STATUS_SUCCESS;
}