From 466b3ce1b094a362f7d2146cca7e07ca38879db4 Mon Sep 17 00:00:00 2001 From: SaidiReddy Yenuga Date: Tue, 2 May 2017 18:50:25 +0530 Subject: [PATCH] qcacld-3.0: Fix memory leak issues in HDD In few instances memory allocated dynamically, but its not freed after usage. free the allocated space after usage. CRs-Fixed: 2041467 Change-Id: Iae551cd3acbb6bc2618f05cfdc33e4f742d63192 --- core/hdd/src/wlan_hdd_cfg80211.c | 2 +- core/hdd/src/wlan_hdd_hostapd.c | 1 + core/hdd/src/wlan_hdd_ioctl.c | 6 ++++-- core/hdd/src/wlan_hdd_ipa.c | 5 ++++- core/hdd/src/wlan_hdd_main.c | 8 ++++++-- core/hdd/src/wlan_hdd_nan_datapath.c | 1 + 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index b5173b1d684a..cf85f57c66b8 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -6002,7 +6002,7 @@ wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx, request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); if (request_id == MAX_REQUEST_ID) { hdd_err("request_id cannot be MAX"); - return -EINVAL; + goto fail; } hdd_debug("Request Id: %u", request_id); diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index fe8d78ce7740..950bd02e8482 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -8563,6 +8563,7 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, params->inactivity_timeout; sme_update_sta_inactivity_timeout(WLAN_HDD_GET_HAL_CTX (pAdapter), sta_inactivity_timer); + qdf_mem_free(sta_inactivity_timer); } } diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index 1b5ff2bf38e8..81b3771a5af8 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -4969,7 +4969,7 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter, if (copy_to_user(priv_data->buf, extra, numOfBytestoPrint)) { hdd_err("Copy into user data buffer failed"); ret = -EFAULT; - goto exit; + goto mem_free; } /* This overwrites the last space, which we already copied */ @@ -4983,7 +4983,7 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter, length - numOfBytestoPrint + 1)) { hdd_err("Copy into user data buffer failed"); ret = -EFAULT; - goto exit; + goto mem_free; } hdd_debug("%s", &extra[numOfBytestoPrint]); } @@ -4999,6 +4999,8 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter, } ret = 0; +mem_free: + qdf_mem_free(extra); exit: return ret; } diff --git a/core/hdd/src/wlan_hdd_ipa.c b/core/hdd/src/wlan_hdd_ipa.c index 6bf3b6d49547..78d7aa808697 100644 --- a/core/hdd/src/wlan_hdd_ipa.c +++ b/core/hdd/src/wlan_hdd_ipa.c @@ -692,10 +692,13 @@ static void hdd_ipa_uc_loaded_uc_cb(void *priv_ctxt) /* When the same uC OPCODE is already pended, just return */ if (uc_op_work->msg) - return; + goto done; uc_op_work->msg = msg; schedule_work(&uc_op_work->work); + +done: + qdf_mem_free(msg); } /** diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 2b2c4761ab2a..a5f89a9c2681 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -8000,7 +8000,7 @@ static int hdd_update_cds_config(hdd_context_t *hdd_ctx) hdd_ctx->config->IpaUcTxBufCount); if (!hdd_ctx->config->IpaUcTxBufCount) { hdd_err("Failed to round down IpaUcTxBufCount"); - return -EINVAL; + goto exit; } hdd_debug("IpaUcTxBufCount rounded down to %d", hdd_ctx->config->IpaUcTxBufCount); @@ -8016,7 +8016,7 @@ static int hdd_update_cds_config(hdd_context_t *hdd_ctx) hdd_ctx->config->IpaUcRxIndRingCount); if (!hdd_ctx->config->IpaUcRxIndRingCount) { hdd_err("Failed to round down IpaUcRxIndRingCount"); - return -EINVAL; + goto exit; } hdd_debug("IpaUcRxIndRingCount rounded down to %d", hdd_ctx->config->IpaUcRxIndRingCount); @@ -8054,6 +8054,10 @@ static int hdd_update_cds_config(hdd_context_t *hdd_ctx) hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); cds_init_ini_config(cds_cfg); return 0; + +exit: + qdf_mem_free(cds_cfg); + return -EINVAL; } /** diff --git a/core/hdd/src/wlan_hdd_nan_datapath.c b/core/hdd/src/wlan_hdd_nan_datapath.c index a1e5eba17444..75fc67ffc903 100644 --- a/core/hdd/src/wlan_hdd_nan_datapath.c +++ b/core/hdd/src/wlan_hdd_nan_datapath.c @@ -1732,6 +1732,7 @@ static void hdd_ndp_end_ind_handler(hdd_adapter_t *adapter, data_len, QCA_NL80211_VENDOR_SUBCMD_NDP_INDEX, GFP_KERNEL); if (!vendor_event) { + qdf_mem_free(ndp_instance_array); hdd_err("cfg80211_vendor_event_alloc failed"); return; }