summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGirish Gowli <c_ggowli@qti.qualcomm.com>2014-06-17 19:28:05 +0530
committerAkash Patel <c_akashp@qca.qualcomm.com>2014-07-11 14:51:37 -0700
commitff20db82fd8a672118c61fb3eed63a18d464d37f (patch)
tree454aeb3b743039075b13d3888156535c73b424e5
parentfd68f0b175ff56c44c67b48ad8e1f87defc393a4 (diff)
wlan: Use mem_alloc_copy_from_user_helper() in iw_softap_setwpsie
Function iw_softap_setwpsie() allocates memory and copies user data using copy_from_user() function. Replacing these two functions with a common helper function mem_alloc_copy_from_user_helper(). Change-Id: I00f80adbdbb0ea83d76770730f5ecc80c077aa5f CRs-Fixed: 690101
-rw-r--r--CORE/HDD/inc/wlan_hdd_wext.h2
-rw-r--r--CORE/HDD/src/wlan_hdd_hostapd.c21
-rw-r--r--CORE/HDD/src/wlan_hdd_wext.c2
3 files changed, 12 insertions, 13 deletions
diff --git a/CORE/HDD/inc/wlan_hdd_wext.h b/CORE/HDD/inc/wlan_hdd_wext.h
index b858ed6e58fb..ced7250f16b1 100644
--- a/CORE/HDD/inc/wlan_hdd_wext.h
+++ b/CORE/HDD/inc/wlan_hdd_wext.h
@@ -389,6 +389,8 @@ extern int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_i
extern int hdd_priv_get_data(struct iw_point *p_priv_data,
union iwreq_data *wrqu);
+extern void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len);
+
extern VOS_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
tSirMacAddr macAddress);
void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter);
diff --git a/CORE/HDD/src/wlan_hdd_hostapd.c b/CORE/HDD/src/wlan_hdd_hostapd.c
index e53abcf72f68..7cf487bd8cea 100644
--- a/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -3716,24 +3716,21 @@ static int iw_softap_setwpsie(struct net_device *dev,
u_int16_t length;
ENTER();
- if(!wrqu->data.length || wrqu->data.length <= QCSAP_MAX_WSC_IE)
+ if(!wrqu->data.length || wrqu->data.length < QCSAP_MAX_WSC_IE)
return 0;
- wps_genie = kmalloc(wrqu->data.length, GFP_KERNEL);
+ wps_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
+ wrqu->data.length);
- if(NULL == wps_genie) {
- hddLog(LOG1, "unable to allocate memory");
- return -ENOMEM;
- }
- fwps_genie = wps_genie;
- if (copy_from_user((void *)wps_genie,
- wrqu->data.pointer, wrqu->data.length))
- {
- hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
- kfree(fwps_genie);
+ if (NULL == wps_genie) {
+ hddLog(LOG1,
+ "%s: failed to alloc memory and copy data from user buffer",
+ __func__);
return -EFAULT;
}
+ fwps_genie = wps_genie;
+
pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
if (NULL == pSap_WPSIe)
{
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index 38c8fd6e2f1a..edff1b2a3762 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -578,7 +578,7 @@ int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
\return - On Success pointer to buffer, On failure NULL
--------------------------------------------------------------------------*/
-static void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
+void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
{
u8 *ptr = NULL;