rtw_malloc prevents the use of kmemdup/kzalloc and others.

Signed-off-by: Ivan Safonov <insafo...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_ap.c        |  4 ++--
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c  |  2 +-
 .../staging/rtl8188eu/include/osdep_service.h  |  3 ---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 18 +++++++++---------
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c  |  2 +-
 .../staging/rtl8188eu/os_dep/osdep_service.c   |  7 +------
 6 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 51a5b71f8c25..c9c57379b7a2 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -104,7 +104,7 @@ static void update_BCNTIM(struct adapter *padapter)
        }
 
        if (remainder_ielen > 0) {
-               pbackup_remainder_ie = rtw_malloc(remainder_ielen);
+               pbackup_remainder_ie = kmalloc(remainder_ielen, in_interrupt() 
? GFP_ATOMIC : GFP_KERNEL);
                if (pbackup_remainder_ie && premainder_ie)
                        memcpy(pbackup_remainder_ie, premainder_ie,
                               remainder_ielen);
@@ -1168,7 +1168,7 @@ static void update_bcn_wps_ie(struct adapter *padapter)
        remainder_ielen = ielen - wps_offset - wps_ielen;
 
        if (remainder_ielen > 0) {
-               pbackup_remainder_ie = rtw_malloc(remainder_ielen);
+               pbackup_remainder_ie = kmalloc(remainder_ielen, in_interrupt() 
? GFP_ATOMIC : GFP_KERNEL);
                if (pbackup_remainder_ie)
                        memcpy(pbackup_remainder_ie, premainder_ie, 
remainder_ielen);
        }
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 18dc9fc1c04a..759a37a5a167 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -2573,7 +2573,7 @@ static unsigned int OnBeacon(struct adapter *padapter,
        if (!memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) {
                if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
                        /* we should update current network before auth, or 
some IE is wrong */
-                       pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct 
wlan_bssid_ex));
+                       pbss = kmalloc(sizeof(*pbss), in_interrupt() ? 
GFP_ATOMIC : GFP_KERNEL);
                        if (pbss) {
                                if (collect_bss_info(padapter, precv_frame, 
pbss) == _SUCCESS) {
                                        
update_network(&pmlmepriv->cur_network.network, pbss, padapter, true);
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h 
b/drivers/staging/rtl8188eu/include/osdep_service.h
index c0114ad79788..dcaa7917b783 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -61,9 +61,6 @@ static inline int rtw_netif_queue_stopped(struct net_device 
*pnetdev)
                netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3));
 }
 
-u8 *_rtw_malloc(u32 sz);
-#define rtw_malloc(sz)                 _rtw_malloc((sz))
-
 void _rtw_init_queue(struct __queue *pqueue);
 
 struct rtw_netdev_priv_indicator {
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index ec5835d1aa8c..04ec73be0cce 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -392,7 +392,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
                if (wep_key_len > 0) {
                        wep_key_len = wep_key_len <= 5 ? 5 : 13;
                        wep_total_len = wep_key_len + offsetof(struct 
ndis_802_11_wep, KeyMaterial);
-                       pwep = (struct ndis_802_11_wep 
*)rtw_malloc(wep_total_len);
+                       pwep = kmalloc(wep_total_len, in_interrupt() ? 
GFP_ATOMIC : GFP_KERNEL);
                        if (!pwep) {
                                RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, 
(" wpa_set_encryption: pwep allocate fail !!!\n"));
                                goto exit;
@@ -1862,7 +1862,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
        int ret = 0;
 
        param_len = sizeof(struct ieee_param) + pext->key_len;
-       param = (struct ieee_param *)rtw_malloc(param_len);
+       param = kmalloc(param_len, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
        if (!param)
                return -1;
 
@@ -2027,7 +2027,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, 
struct iw_point *p)
                goto out;
        }
 
-       param = (struct ieee_param *)rtw_malloc(p->length);
+       param = kmalloc(p->length, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
        if (!param) {
                ret = -ENOMEM;
                goto out;
@@ -2236,7 +2236,7 @@ static int rtw_set_encryption(struct net_device *dev, 
struct ieee_param *param,
                if (wep_key_len > 0) {
                        wep_key_len = wep_key_len <= 5 ? 5 : 13;
                        wep_total_len = wep_key_len + offsetof(struct 
ndis_802_11_wep, KeyMaterial);
-                       pwep = (struct ndis_802_11_wep 
*)rtw_malloc(wep_total_len);
+                       pwep = kmalloc(wep_total_len, in_interrupt() ? 
GFP_ATOMIC : GFP_KERNEL);
                        if (!pwep) {
                                DBG_88E(" r871x_set_encryption: pwep allocate 
fail !!!\n");
                                goto exit;
@@ -2652,7 +2652,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, 
struct ieee_param *param,
        pmlmepriv->wps_beacon_ie = NULL;
 
        if (ie_len > 0) {
-               pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len);
+               pmlmepriv->wps_beacon_ie = kmalloc(ie_len, in_interrupt() ? 
GFP_ATOMIC : GFP_KERNEL);
                pmlmepriv->wps_beacon_ie_len = ie_len;
                if (!pmlmepriv->wps_beacon_ie) {
                        DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, 
__LINE__);
@@ -2686,7 +2686,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, 
struct ieee_param *par
        pmlmepriv->wps_probe_resp_ie = NULL;
 
        if (ie_len > 0) {
-               pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len);
+               pmlmepriv->wps_probe_resp_ie = kmalloc(ie_len, in_interrupt() ? 
GFP_ATOMIC : GFP_KERNEL);
                pmlmepriv->wps_probe_resp_ie_len = ie_len;
                if (!pmlmepriv->wps_probe_resp_ie) {
                        DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, 
__LINE__);
@@ -2715,7 +2715,7 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, 
struct ieee_param *par
        pmlmepriv->wps_assoc_resp_ie = NULL;
 
        if (ie_len > 0) {
-               pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len);
+               pmlmepriv->wps_assoc_resp_ie = kmalloc(ie_len, in_interrupt() ? 
GFP_ATOMIC : GFP_KERNEL);
                pmlmepriv->wps_assoc_resp_ie_len = ie_len;
                if (!pmlmepriv->wps_assoc_resp_ie) {
                        DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, 
__LINE__);
@@ -2814,7 +2814,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, 
struct iw_point *p)
                goto out;
        }
 
-       param = (struct ieee_param *)rtw_malloc(p->length);
+       param = kmalloc(p->length, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
        if (!param) {
                ret = -ENOMEM;
                goto out;
@@ -2924,7 +2924,7 @@ static int rtw_wx_set_priv(struct net_device *dev,
                        kfree(pmlmepriv->wps_probe_req_ie);
                        pmlmepriv->wps_probe_req_ie = NULL;
 
-                       pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz);
+                       pmlmepriv->wps_probe_req_ie = kmalloc(cp_sz, 
in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
                        if (!pmlmepriv->wps_probe_req_ie) {
                                pr_info("%s()-%d: rtw_malloc() ERROR!\n", 
__func__, __LINE__);
                                ret =  -EINVAL;
diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c 
b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
index 321b2c46479c..e6065fff276f 100644
--- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
@@ -93,7 +93,7 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, 
u8 *sec_ie)
        if (authmode == _WPA_IE_ID_) {
                RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
                         ("%s, authmode=%d\n", __func__, authmode));
-               buff = rtw_malloc(IW_CUSTOM_MAX);
+               buff = kmalloc(IW_CUSTOM_MAX, in_interrupt() ? GFP_ATOMIC : 
GFP_KERNEL);
                if (!buff)
                        return;
                memset(buff, 0, IW_CUSTOM_MAX);
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 69d4b1d66b6f..ce6d3929b0d6 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -13,11 +13,6 @@
 #include <linux/vmalloc.h>
 #include <rtw_ioctl_set.h>
 
-u8 *_rtw_malloc(u32 sz)
-{
-       return kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
-}
-
 void _rtw_init_queue(struct __queue *pqueue)
 {
        INIT_LIST_HEAD(&pqueue->queue);
@@ -79,7 +74,7 @@ void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 
src_len)
                goto keep_ori;
 
        /* duplicate src */
-       dup = rtw_malloc(src_len);
+       dup = kmalloc(src_len, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
        if (dup) {
                dup_len = src_len;
                memcpy(dup, src, dup_len);
-- 
2.21.0

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to