From 759b327f8fbbbed4ac752fc34b62d0a3240d3419 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Dhanotiya Date: Fri, 18 May 2018 17:49:46 +0530 Subject: [PATCH] qcacld-3.0: Avoid mem leak during con_mode change If any userspace request is posted using request manager, memory is allocated for that request using hdd_request_alloc api. Now when the response of this request comes in the registered callback, if this response is NULL then callback returns without doing hdd_request_complete and eventually request gets timed out and memory is released through request_put. If the con_mode is changed before this time out occures, con_mode_handler will try to stop_modules and will result in mem leak detection as the memory for the request is not released yet. To address this issue in con_mode_handler, wait for all the user space requests to complete before trying to stop modules. Change-Id: If524580e420d107a1fe6d17b75d4c13e4feb96e1 CRs-Fixed: 2244739 --- core/hdd/src/wlan_hdd_main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 7cf51112dd02..17432661be40 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -12646,6 +12646,11 @@ static int con_mode_handler(const char *kmessage, const struct kernel_param *kp) if (ret) return ret; + if (!cds_wait_for_external_threads_completion(__func__)) { + hdd_warn("External threads are still active, can not change mode"); + return -EAGAIN; + } + cds_ssr_protect(__func__); ret = __con_mode_handler(kmessage, kp, hdd_ctx); cds_ssr_unprotect(__func__);