summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Kumar Dhanotiya <adhanoti@codeaurora.org>2019-07-23 15:50:10 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2019-10-16 00:08:28 -0700
commitb87208ef69dbcbfaedb8397667c74b5d99e18092 (patch)
tree50216cde02a21a6486478e14c52000634d95662b
parentd714782be1b68d928148a8290a4347effe850d7c (diff)
qcacld-3.0: Fix memory leak in driver dump
Currently when driver gets a command to dump the driver info, it allocates the memory and retrieves the information in that allocated memory. Maximum data that can be copied to user space buffer is equal to one PAGE_SIZE. In the command driver gets the size of the data which user space wants to read, minimum of the user space requested size or one PAGE_SIZE of the data is copied to user space buffer and current position of the driver buffer till which the data is copied is updated to user space is also updated. Driver copies the retrieved information to the user space buffer as explained above and updates the position pointer to the user space. In the next request driver expects from user space to request the remaining data from the updated position in last request, once all the data is copied to user space, driver frees internally allocated memory. In case if driver does not get the request to read remaining data after first request, it does not free the memory. Current handling of this memory is done in init domain after stop modules, but since this memory is allocated in active domain, driver should free the memory in active domain. Since with current implementation memory allocated in active domain is not freed in active domain, memleak is getting detected. To resolve above issue, move mem cleanup logic for driver dump info command from init domain to active domain in stop modules. Change-Id: Idb4f35f0a599ad55eebe13348b68562fa401fd7e CRs-Fixed: 2489877
-rw-r--r--core/hdd/inc/wlan_hdd_main.h10
-rw-r--r--core/hdd/src/wlan_hdd_main.c1
-rw-r--r--core/hdd/src/wlan_hdd_memdump.c14
3 files changed, 13 insertions, 12 deletions
diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h
index 98b9801c3521..0312da3f6601 100644
--- a/core/hdd/inc/wlan_hdd_main.h
+++ b/core/hdd/inc/wlan_hdd_main.h
@@ -3270,6 +3270,16 @@ int hdd_driver_memdump_init(void);
void hdd_driver_memdump_deinit(void);
/**
+ * hdd_driver_mem_cleanup() - Frees memory allocated for
+ * driver dump
+ *
+ * This function frees driver dump memory.
+ *
+ * Return: None
+ */
+void hdd_driver_mem_cleanup(void);
+
+/**
* wlan_hdd_free_cache_channels() - Free the cache channels list
* @hdd_ctx: Pointer to HDD context
*
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 2da610d8989d..24e2a9967fa9 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -11300,6 +11300,7 @@ int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx, bool ftm_mode)
}
/* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */
wlan_hdd_free_cache_channels(hdd_ctx);
+ hdd_driver_mem_cleanup();
/* many adapter resources are not freed by design in SSR case */
if (!is_recover_stop)
diff --git a/core/hdd/src/wlan_hdd_memdump.c b/core/hdd/src/wlan_hdd_memdump.c
index ff048ba6be71..d0a834d7e298 100644
--- a/core/hdd/src/wlan_hdd_memdump.c
+++ b/core/hdd/src/wlan_hdd_memdump.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -61,15 +61,7 @@ static void *memdump_get_file_data(struct file *file)
return hdd_ctx;
}
-/**
- * hdd_driver_mem_cleanup() - Frees memory allocated for
- * driver dump
- *
- * This function unallocates driver dump memory.
- *
- * Return: None
- */
-static void hdd_driver_mem_cleanup(void)
+void hdd_driver_mem_cleanup(void)
{
hdd_context_t *hdd_ctx;
@@ -307,6 +299,4 @@ int hdd_driver_memdump_init(void)
void hdd_driver_memdump_deinit(void)
{
hdd_driver_memdump_procfs_remove();
-
- hdd_driver_mem_cleanup();
}