From 493a31be99f4454ee7abfdd1e7d42bc82745b533 Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Date: Fri, 29 Sep 2017 14:01:24 -0700 Subject: [PATCH] qcacld-3.0: Set hdd context to null when its freed HDD context in gp_cds_context is not getting reset to null during driver remove callback when hdd context is destroyed. Set HDD context to null to avoid any use after free. Change-Id: Ifbeaca139ed44f871266a11f4b9e973961e26cc8 CRs-Fixed: 2119187 --- core/hdd/src/wlan_hdd_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index dfff0d48f254..f2f9b02159f8 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -5865,6 +5865,7 @@ static int hdd_context_deinit(struct hdd_context *hdd_ctx) */ static void hdd_context_destroy(struct hdd_context *hdd_ctx) { + cds_set_context(QDF_MODULE_ID_HDD, NULL); wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); @@ -7782,8 +7783,6 @@ static struct hdd_context *hdd_context_create(struct device *dev) hdd_override_ini_config(hdd_ctx); - cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); - ret = hdd_context_init(hdd_ctx); if (ret) @@ -7811,6 +7810,8 @@ static struct hdd_context *hdd_context_create(struct device *dev) skip_multicast_logging: hdd_set_trace_level_for_each(hdd_ctx); + cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); + EXIT(); return hdd_ctx;