summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>2016-11-02 10:28:03 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2017-01-06 20:49:57 -0800
commit9fc2e07576b62f10961c0ecd59d2665d5088be26 (patch)
tree282164582fcaaa1fd90c09f4667f1bc408b33374
parent70af8564bae3279da1bf6756d0892e375168551e (diff)
qcacld-3.0: use QDF API for mem allocation
Replace usage of k[mz]alloc()/kfree() with qdf_mem_malloc()/ qdf_mem_free(). The API qdf_mem_malloc() calls kzalloc() with proper allocation flags depending on the context. QDF module has debugging capabilities like detect memory leak, list allocation..etc. Change-Id: I6655bc54675b5bdc0a8ce17753a08205e711d806 CRs-Fixed: 1085826
-rw-r--r--core/hdd/src/wlan_hdd_assoc.c37
-rw-r--r--core/hdd/src/wlan_hdd_cfg80211.c8
-rw-r--r--core/hdd/src/wlan_hdd_ftm.c14
-rw-r--r--core/hdd/src/wlan_hdd_hostapd.c6
-rw-r--r--core/hdd/src/wlan_hdd_ioctl.c14
-rw-r--r--core/hdd/src/wlan_hdd_power.c4
-rw-r--r--core/hdd/src/wlan_hdd_wext.c12
-rw-r--r--core/hdd/src/wlan_hdd_wmm.c10
-rw-r--r--core/hdd/src/wlan_hdd_wowl.c10
9 files changed, 56 insertions, 59 deletions
diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c
index 9adf7d3fc850..da532aaba542 100644
--- a/core/hdd/src/wlan_hdd_assoc.c
+++ b/core/hdd/src/wlan_hdd_assoc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -933,19 +933,18 @@ hdd_send_ft_assoc_response(struct net_device *dev,
(unsigned int)pFTAssocRsp[1]);
/* We need to send the IEs to the supplicant. */
- buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
+ buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
if (buff == NULL) {
- hdd_err("kmalloc unable to allocate memory");
+ hdd_err("unable to allocate memory");
return;
}
/* Send the Assoc Resp, the supplicant needs this for initial Auth. */
len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
wrqu.data.length = len;
- memset(buff, 0, IW_GENERIC_IE_MAX);
memcpy(buff, pFTAssocRsp, len);
wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
- kfree(buff);
+ qdf_mem_free(buff);
}
/**
@@ -1018,12 +1017,11 @@ static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
#else
/* We need to send the IEs to the supplicant */
- buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
+ buff = qdf_mem_malloc(IW_CUSTOM_MAX);
if (buff == NULL) {
- hdd_err("kmalloc unable to allocate memory");
+ hdd_err("unable to allocate memory");
return;
}
- qdf_mem_zero(buff, IW_CUSTOM_MAX);
/* Sme needs to send the RIC IEs first */
str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
@@ -1045,7 +1043,7 @@ static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
(IW_CUSTOM_MAX - str_len), &auth_resp_len);
if (auth_resp_len == 0) {
- kfree(buff);
+ qdf_mem_free(buff);
hdd_err("AuthRsp FTIES is of length 0");
return;
}
@@ -1053,7 +1051,7 @@ static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
wrqu.data.length = str_len + auth_resp_len;
wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
- kfree(buff);
+ qdf_mem_free(buff);
#endif
}
@@ -1133,12 +1131,11 @@ hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
/* We need to send the IEs to the supplicant. */
- buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
+ buff = qdf_mem_malloc(IW_CUSTOM_MAX);
if (buff == NULL) {
- hdd_err("kmalloc unable to allocate memory");
+ hdd_err("unable to allocate memory");
return;
}
- qdf_mem_zero(buff, IW_CUSTOM_MAX);
strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
currentLen = strLen + 1;
@@ -1168,7 +1165,7 @@ hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
} while (totalIeLen > 0);
- kfree(buff);
+ qdf_mem_free(buff);
}
/**
@@ -1892,8 +1889,8 @@ static void hdd_send_re_assoc_event(struct net_device *dev,
{
unsigned int len = 0;
u8 *pFTAssocRsp = NULL;
- uint8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
- uint8_t *assoc_req_ies = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
+ uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
+ uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
uint32_t rspRsnLength = 0;
struct ieee80211_channel *chan;
uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
@@ -1980,7 +1977,7 @@ static void hdd_send_re_assoc_event(struct net_device *dev,
hdd_notice("SSIDIE:");
QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
buf_ssid_ie, ssid_ie_len);
- final_req_ie = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
+ final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
if (final_req_ie == NULL)
goto done;
buf_ptr = final_req_ie;
@@ -2012,9 +2009,9 @@ static void hdd_send_re_assoc_event(struct net_device *dev,
done:
sme_roam_free_connect_profile(&roam_profile);
if (final_req_ie)
- kfree(final_req_ie);
- kfree(rspRsnIe);
- kfree(assoc_req_ies);
+ qdf_mem_free(final_req_ie);
+ qdf_mem_free(rspRsnIe);
+ qdf_mem_free(assoc_req_ies);
}
/**
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index df3ef783c18b..38d3cc2aba87 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -11124,7 +11124,7 @@ struct cfg80211_bss *wlan_hdd_cfg80211_inform_bss_frame(hdd_adapter_t *pAdapter,
return NULL;
cfg_param = pHddCtx->config;
- mgmt = kzalloc((sizeof(struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
+ mgmt = qdf_mem_malloc((sizeof(struct ieee80211_mgmt) + ie_length));
if (!mgmt) {
hdd_err("memory allocation failed");
return NULL;
@@ -11188,7 +11188,7 @@ struct cfg80211_bss *wlan_hdd_cfg80211_inform_bss_frame(hdd_adapter_t *pAdapter,
NL80211_BAND_5GHZ);
} else {
hdd_err("Invalid chan_no %d", chan_no);
- kfree(mgmt);
+ qdf_mem_free(mgmt);
return NULL;
}
@@ -11217,7 +11217,7 @@ struct cfg80211_bss *wlan_hdd_cfg80211_inform_bss_frame(hdd_adapter_t *pAdapter,
if (chan == NULL) {
hdd_err("chan pointer is NULL, chan_no: %d freq: %d",
chan_no, freq);
- kfree(mgmt);
+ qdf_mem_free(mgmt);
return NULL;
}
@@ -11239,7 +11239,7 @@ struct cfg80211_bss *wlan_hdd_cfg80211_inform_bss_frame(hdd_adapter_t *pAdapter,
bss_status =
cfg80211_inform_bss_frame(wiphy, chan, mgmt, frame_len, rssi,
GFP_KERNEL);
- kfree(mgmt);
+ qdf_mem_free(mgmt);
return bss_status;
}
diff --git a/core/hdd/src/wlan_hdd_ftm.c b/core/hdd/src/wlan_hdd_ftm.c
index 274932007ec3..d606e033efe1 100644
--- a/core/hdd/src/wlan_hdd_ftm.c
+++ b/core/hdd/src/wlan_hdd_ftm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -219,7 +219,7 @@ static int wlan_hdd_qcmbr_command(hdd_adapter_t *adapter,
if (!ret) {
memcpy(pqcmbr_data->buf, qcmbr_buf->utf_buf,
(MAX_UTF_LENGTH + 4));
- kfree(qcmbr_buf);
+ qdf_mem_free(qcmbr_buf);
} else {
ret = -EAGAIN;
}
@@ -244,7 +244,7 @@ static int wlan_hdd_qcmbr_compat_ioctl(hdd_adapter_t *adapter,
qcmbr_data_t *qcmbr_data;
int ret = 0;
- qcmbr_data = kzalloc(sizeof(qcmbr_data_t), GFP_KERNEL);
+ qcmbr_data = qdf_mem_malloc(sizeof(qcmbr_data_t));
if (qcmbr_data == NULL)
return -ENOMEM;
@@ -260,7 +260,7 @@ static int wlan_hdd_qcmbr_compat_ioctl(hdd_adapter_t *adapter,
}
exit:
- kfree(qcmbr_data);
+ qdf_mem_free(qcmbr_data);
return ret;
}
#else /* CONFIG_COMPAT */
@@ -283,7 +283,7 @@ static int wlan_hdd_qcmbr_ioctl(hdd_adapter_t *adapter, struct ifreq *ifr)
qcmbr_data_t *qcmbr_data;
int ret = 0;
- qcmbr_data = kzalloc(sizeof(qcmbr_data_t), GFP_KERNEL);
+ qcmbr_data = qdf_mem_malloc(sizeof(qcmbr_data_t));
if (qcmbr_data == NULL)
return -ENOMEM;
@@ -299,7 +299,7 @@ static int wlan_hdd_qcmbr_ioctl(hdd_adapter_t *adapter, struct ifreq *ifr)
}
exit:
- kfree(qcmbr_data);
+ qdf_mem_free(qcmbr_data);
return ret;
}
@@ -335,7 +335,7 @@ static void wlanqcmbr_mc_process_msg(void *message)
uint32_t data_len;
data_len = *((uint32_t *) message) + sizeof(uint32_t);
- qcmbr_buf = kzalloc(sizeof(qcmbr_queue_t), GFP_KERNEL);
+ qcmbr_buf = qdf_mem_malloc(sizeof(qcmbr_queue_t));
if (qcmbr_buf != NULL) {
memcpy(qcmbr_buf->utf_buf, message, data_len);
spin_lock_bh(&qcmbr_queue_lock);
diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c
index fc26dab8bfe0..bd97e3e64397 100644
--- a/core/hdd/src/wlan_hdd_hostapd.c
+++ b/core/hdd/src/wlan_hdd_hostapd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -3816,7 +3816,7 @@ static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
}
/* allocate local buffer to build the response */
- buf = kmalloc(wrqu->data.length, GFP_KERNEL);
+ buf = qdf_mem_malloc(wrqu->data.length);
if (!buf) {
hdd_notice("failed to allocate response buffer");
return -ENOMEM;
@@ -3845,7 +3845,7 @@ static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
hdd_notice("failed to copy response to user buffer");
ret = -EFAULT;
}
- kfree(buf);
+ qdf_mem_free(buf);
EXIT();
return ret;
}
diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c
index ab61c7aa92b7..26a91a791de9 100644
--- a/core/hdd/src/wlan_hdd_ioctl.c
+++ b/core/hdd/src/wlan_hdd_ioctl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -5055,11 +5055,11 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter,
* exceeds the size of 1024 bytes of default stack size. On
* 64 bit devices, the default max stack size of 2048 bytes
*/
- extra = kmalloc(WLAN_MAX_BUF_SIZE, GFP_KERNEL);
+ extra = qdf_mem_malloc(WLAN_MAX_BUF_SIZE);
if (NULL == extra) {
- hdd_err("kmalloc failed");
- ret = -EINVAL;
+ hdd_err("memory allocation failed");
+ ret = -ENOMEM;
goto exit;
}
@@ -5130,7 +5130,7 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter,
}
/* Free temporary buffer */
- kfree(extra);
+ qdf_mem_free(extra);
} else {
/* Command failed, log error */
hdd_err("GETIBSSPEERINFOALL command failed with status code %d",
@@ -7002,7 +7002,7 @@ static int hdd_driver_command(hdd_adapter_t *adapter,
}
/* Allocate +1 for '\0' */
- command = kmalloc(priv_data->total_len + 1, GFP_KERNEL);
+ command = qdf_mem_malloc(priv_data->total_len + 1);
if (!command) {
hdd_err("failed to allocate memory");
ret = -ENOMEM;
@@ -7022,7 +7022,7 @@ static int hdd_driver_command(hdd_adapter_t *adapter,
exit:
if (command)
- kfree(command);
+ qdf_mem_free(command);
EXIT();
return ret;
}
diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c
index 2936eb4b6536..ff4a9ce98f33 100644
--- a/core/hdd/src/wlan_hdd_power.c
+++ b/core/hdd/src/wlan_hdd_power.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -1613,7 +1613,7 @@ err_wiphy_unregister:
nl_srv_exit();
/* Free up dynamically allocated members inside HDD Adapter */
- kfree(pHddCtx->config);
+ qdf_mem_free(pHddCtx->config);
pHddCtx->config = NULL;
wlan_hdd_deinit_tx_rx_histogram(pHddCtx);
wiphy_unregister(pHddCtx->wiphy);
diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c
index 927f425decf0..c362daa7df08 100644
--- a/core/hdd/src/wlan_hdd_wext.c
+++ b/core/hdd/src/wlan_hdd_wext.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -1071,7 +1071,7 @@ void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
return NULL;
}
- ptr = kmalloc(len + 1, GFP_KERNEL);
+ ptr = qdf_mem_malloc(len + 1);
if (NULL == ptr) {
hdd_err("unable to allocate memory");
return NULL;
@@ -1079,7 +1079,7 @@ void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
if (copy_from_user(ptr, wrqu_data, len)) {
hdd_err("failed to copy data to user buffer");
- kfree(ptr);
+ qdf_mem_free(ptr);
return NULL;
}
ptr[len] = '\0';
@@ -3444,7 +3444,7 @@ static int __iw_set_genie(struct net_device *dev,
}
exit:
EXIT();
- kfree(base_genie);
+ qdf_mem_free(base_genie);
return ret;
}
@@ -7049,7 +7049,7 @@ static int __iw_setchar_getnone(struct net_device *dev,
break;
}
}
- kfree(pBuffer);
+ qdf_mem_free(pBuffer);
EXIT();
return ret;
}
@@ -9625,7 +9625,7 @@ static int __iw_set_packet_filter_params(struct net_device *dev,
ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
- kfree(request);
+ qdf_mem_free(request);
EXIT();
return ret;
}
diff --git a/core/hdd/src/wlan_hdd_wmm.c b/core/hdd/src/wlan_hdd_wmm.c
index 9cfb8f3b02c7..f9256a7ad064 100644
--- a/core/hdd/src/wlan_hdd_wmm.c
+++ b/core/hdd/src/wlan_hdd_wmm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -275,7 +275,7 @@ static void hdd_wmm_free_context(hdd_wmm_qos_context_t *pQosContext)
mutex_unlock(&pAdapter->hddWmmStatus.wmmLock);
/* reclaim memory */
- kfree(pQosContext);
+ qdf_mem_free(pQosContext);
}
@@ -1041,7 +1041,7 @@ static void __hdd_wmm_do_implicit_qos(struct work_struct *work)
if (!pAc->wmmAcAccessNeeded) {
hdd_err("AC %d doesn't need service", acType);
pQosContext->magic = 0;
- kfree(pQosContext);
+ qdf_mem_free(pQosContext);
return;
}
@@ -1751,7 +1751,7 @@ QDF_STATUS hdd_wmm_acquire_access(hdd_adapter_t *pAdapter,
pAdapter->hddWmmStatus.wmmAcStatus[acType].wmmAcAccessNeeded = true;
- pQosContext = kmalloc(sizeof(*pQosContext), GFP_ATOMIC);
+ pQosContext = qdf_mem_malloc(sizeof(*pQosContext));
if (NULL == pQosContext) {
/* no memory for QoS context. Nothing we can do but
* let data flow
@@ -2137,7 +2137,7 @@ hdd_wlan_wmm_status_e hdd_wmm_addts(hdd_adapter_t *pAdapter,
return status;
}
- pQosContext = kmalloc(sizeof(*pQosContext), GFP_KERNEL);
+ pQosContext = qdf_mem_malloc(sizeof(*pQosContext));
if (NULL == pQosContext) {
/* no memory for QoS context. Nothing we can do */
hdd_err("Unable to allocate QoS context");
diff --git a/core/hdd/src/wlan_hdd_wowl.c b/core/hdd/src/wlan_hdd_wowl.c
index fa1c7af7d15e..ada01b23af3c 100644
--- a/core/hdd/src/wlan_hdd_wowl.c
+++ b/core/hdd/src/wlan_hdd_wowl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -215,9 +215,9 @@ bool hdd_add_wowl_ptrn(hdd_adapter_t *pAdapter, const char *ptrn)
/* All is good. Store the pattern locally */
g_hdd_wowl_ptrns[first_empty_slot] =
- kmalloc(len + 1, GFP_KERNEL);
+ qdf_mem_malloc(len + 1);
if (g_hdd_wowl_ptrns[first_empty_slot] == NULL) {
- hdd_err(" kmalloc failure");
+ hdd_err("memory allocation failure");
return false;
}
@@ -235,7 +235,7 @@ bool hdd_add_wowl_ptrn(hdd_adapter_t *pAdapter, const char *ptrn)
/* Add failed, so invalidate the local storage */
hdd_err("sme_wowl_add_bcast_pattern failed with error code (%d)",
qdf_ret_status);
- kfree(g_hdd_wowl_ptrns[first_empty_slot]);
+ qdf_mem_free(g_hdd_wowl_ptrns[first_empty_slot]);
g_hdd_wowl_ptrns[first_empty_slot] = NULL;
}
@@ -293,7 +293,7 @@ bool hdd_del_wowl_ptrn(hdd_adapter_t *pAdapter, const char *ptrn)
hdd_err("Deleted pattern with id %d [%s]", id,
g_hdd_wowl_ptrns[id]);
- kfree(g_hdd_wowl_ptrns[id]);
+ qdf_mem_free(g_hdd_wowl_ptrns[id]);
g_hdd_wowl_ptrns[id] = NULL;
return true;
}