staging: r8188eu: Remove wrappers for kalloc() and kzalloc()

These wrappers involve an in_interrupt() call, which is not frowned on
in the kernel. These changes decrease the size of the driver by a trivial
amount.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Link: https://lore.kernel.org/r/20210805183717.23007-2-Larry.Finger@lwfinger.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Larry Finger 2021-08-05 13:37:13 -05:00 committed by Greg Kroah-Hartman
parent 66e9564aae
commit 79f712ea99
20 changed files with 86 additions and 115 deletions

View File

@ -98,7 +98,7 @@ static void update_BCNTIM(struct adapter *padapter)
} }
if (remainder_ielen > 0) { if (remainder_ielen > 0) {
pbackup_remainder_ie = rtw_malloc(remainder_ielen); pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL);
if (pbackup_remainder_ie && premainder_ie) if (pbackup_remainder_ie && premainder_ie)
memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
} }
@ -180,7 +180,7 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8
} }
if (remainder_ielen > 0) { if (remainder_ielen > 0) {
pbackup_remainder_ie = rtw_malloc(remainder_ielen); pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL);
if (pbackup_remainder_ie && premainder_ie) if (pbackup_remainder_ie && premainder_ie)
memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
} }
@ -224,7 +224,7 @@ void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork,
} }
if (remainder_ielen > 0) { if (remainder_ielen > 0) {
pbackup_remainder_ie = rtw_malloc(remainder_ielen); pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL);
if (pbackup_remainder_ie && premainder_ie) if (pbackup_remainder_ie && premainder_ie)
memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
} }
@ -1302,7 +1302,7 @@ static void update_bcn_wps_ie(struct adapter *padapter)
remainder_ielen = ielen - wps_offset - wps_ielen; remainder_ielen = ielen - wps_offset - wps_ielen;
if (remainder_ielen > 0) { if (remainder_ielen > 0) {
pbackup_remainder_ie = rtw_malloc(remainder_ielen); pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL);
if (pbackup_remainder_ie) if (pbackup_remainder_ie)
memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
} }

View File

@ -394,7 +394,7 @@ static void __nat25_db_network_insert(struct adapter *priv,
} }
db = db->next_hash; db = db->next_hash;
} }
db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db)); db = kmalloc(sizeof(*db), GFP_KERNEL);
if (!db) { if (!db) {
spin_unlock_bh(&priv->br_ext_lock); spin_unlock_bh(&priv->br_ext_lock);
return; return;

View File

@ -1947,11 +1947,14 @@ static void c2h_wk_callback(struct work_struct *work)
if ((c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) { if ((c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) {
/* This C2H event is read, clear it */ /* This C2H event is read, clear it */
c2h_evt_clear(adapter); c2h_evt_clear(adapter);
} else if ((c2h_evt = (struct c2h_evt_hdr *)rtw_malloc(16)) != NULL) { } else {
c2h_evt = kmalloc(16, GFP_KERNEL);
if (c2h_evt) {
/* This C2H event is not read, read & clear now */ /* This C2H event is not read, read & clear now */
if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS)
continue; continue;
} }
}
/* Special pointer to trigger c2h_evt_clear only */ /* Special pointer to trigger c2h_evt_clear only */
if ((void *)c2h_evt == (void *)evtpriv) if ((void *)c2h_evt == (void *)evtpriv)

View File

@ -533,7 +533,7 @@ u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data)
if ((addr + cnts) > mapLen) if ((addr + cnts) > mapLen)
return _FAIL; return _FAIL;
map = rtw_zmalloc(mapLen); map = kzalloc(mapLen, GFP_KERNEL);
if (!map) if (!map)
return _FAIL; return _FAIL;
@ -625,7 +625,7 @@ u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data
if ((addr + cnts) > mapLen) if ((addr + cnts) > mapLen)
return _FAIL; return _FAIL;
map = rtw_zmalloc(mapLen); map = kzalloc(mapLen, GFP_KERNEL);
if (!map) if (!map)
return _FAIL; return _FAIL;

View File

@ -1735,13 +1735,13 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); struct cmd_priv *pcmdpriv = &(adapter->cmdpriv);
int res = _SUCCESS; int res = _SUCCESS;
pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (!pcmd) { if (!pcmd) {
res = _FAIL; /* try again */ res = _FAIL; /* try again */
goto exit; goto exit;
} }
psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm)); psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL);
if (!psetauthparm) { if (!psetauthparm) {
kfree(pcmd); kfree(pcmd);
res = _FAIL; res = _FAIL;
@ -1773,12 +1773,12 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
int res = _SUCCESS; int res = _SUCCESS;
pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (!pcmd) { if (!pcmd) {
res = _FAIL; /* try again */ res = _FAIL; /* try again */
goto exit; goto exit;
} }
psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
if (!psetkeyparm) { if (!psetkeyparm) {
kfree(pcmd); kfree(pcmd);
res = _FAIL; res = _FAIL;

View File

@ -662,7 +662,7 @@ unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame)
if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) {
if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
/* we should update current network before auth, or some IE is wrong */ /* 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(struct wlan_bssid_ex), GFP_ATOMIC);
if (pbss) { if (pbss) {
if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) {
update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true);
@ -6966,12 +6966,12 @@ void report_survey_event(struct adapter *padapter, struct recv_frame *precv_fram
pmlmeext = &padapter->mlmeextpriv; pmlmeext = &padapter->mlmeextpriv;
pcmdpriv = &padapter->cmdpriv; pcmdpriv = &padapter->cmdpriv;
pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (!pcmd_obj) if (!pcmd_obj)
return; return;
cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz); pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
if (!pevtcmd) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
@ -7016,12 +7016,12 @@ void report_surveydone_event(struct adapter *padapter)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (!pcmd_obj) if (!pcmd_obj)
return; return;
cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz); pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (!pevtcmd) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
@ -7060,12 +7060,12 @@ void report_join_res(struct adapter *padapter, int res)
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (!pcmd_obj) if (!pcmd_obj)
return; return;
cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz); pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
if (!pevtcmd) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
@ -7109,12 +7109,12 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (!pcmd_obj) if (!pcmd_obj)
return; return;
cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header)); cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz); pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (!pevtcmd) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
@ -7161,12 +7161,12 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (!pcmd_obj) if (!pcmd_obj)
return; return;
cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header)); cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz); pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (!pevtcmd) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
@ -7582,11 +7582,11 @@ void survey_timer_hdl(struct adapter *padapter)
pmlmeext->scan_abort = false;/* reset */ pmlmeext->scan_abort = false;/* reset */
} }
ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (!ph2c) if (!ph2c)
goto exit_survey_timer_hdl; goto exit_survey_timer_hdl;
psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
if (!psurveyPara) { if (!psurveyPara) {
kfree(ph2c); kfree(ph2c);
goto exit_survey_timer_hdl; goto exit_survey_timer_hdl;
@ -8158,13 +8158,13 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)
u8 res = _SUCCESS; u8 res = _SUCCESS;
int len_diff = 0; int len_diff = 0;
ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (!ph2c) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param)); ptxBeacon_parm = kzalloc(sizeof(struct Tx_Beacon_param), GFP_KERNEL);
if (!ptxBeacon_parm) { if (!ptxBeacon_parm) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;

View File

@ -669,7 +669,7 @@ void SetPacketTx(struct adapter *padapter)
kfree(pmp_priv->tx.pallocated_buf); kfree(pmp_priv->tx.pallocated_buf);
pmp_priv->tx.write_size = pkt_size; pmp_priv->tx.write_size = pkt_size;
pmp_priv->tx.buf_size = pkt_size + XMITBUF_ALIGN_SZ; pmp_priv->tx.buf_size = pkt_size + XMITBUF_ALIGN_SZ;
pmp_priv->tx.pallocated_buf = rtw_zmalloc(pmp_priv->tx.buf_size); pmp_priv->tx.pallocated_buf = kzalloc(pmp_priv->tx.buf_size, GFP_KERNEL);
if (!pmp_priv->tx.pallocated_buf) { if (!pmp_priv->tx.pallocated_buf) {
DBG_88E("%s: malloc(%d) fail!!\n", __func__, pmp_priv->tx.buf_size); DBG_88E("%s: malloc(%d) fail!!\n", __func__, pmp_priv->tx.buf_size);
return; return;

View File

@ -34,7 +34,7 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf)
DBG_88E("%s\n", __func__); DBG_88E("%s\n", __func__);
pdata_attr = rtw_zmalloc(MAX_P2P_IE_LEN); pdata_attr = kzalloc(MAX_P2P_IE_LEN, GFP_KERNEL);
pstart = pdata_attr; pstart = pdata_attr;
pcur = pdata_attr; pcur = pdata_attr;
@ -855,7 +855,7 @@ u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l
/* Check P2P Device Info ATTR */ /* Check P2P Device Info ATTR */
if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint *)&attr_contentlen)) { if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint *)&attr_contentlen)) {
DBG_88E("[%s] Got P2P DEVICE INFO Attr!!\n", __func__); DBG_88E("[%s] Got P2P DEVICE INFO Attr!!\n", __func__);
pattr_content = rtw_zmalloc(attr_contentlen); pattr_content = kzalloc(attr_contentlen, GFP_KERNEL);
pbuf = pattr_content; pbuf = pattr_content;
if (pattr_content) { if (pattr_content) {
u8 num_of_secdev_type; u8 num_of_secdev_type;
@ -1697,13 +1697,13 @@ u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue)
return res; return res;
if (enqueue) { if (enqueue) {
ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (!ph2c) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
if (!pdrvextra_cmd_parm) { if (!pdrvextra_cmd_parm) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;

View File

@ -915,7 +915,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
return true; return true;
} }
bssid = (struct wlan_bssid_ex *)rtw_zmalloc(sizeof(struct wlan_bssid_ex)); bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC);
if (!bssid) if (!bssid)
return _FAIL; return _FAIL;

View File

@ -1625,7 +1625,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; pxmitpriv->hwxmit_entry = HWXMIT_ENTRY;
pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); pxmitpriv->hwxmits = kzalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, GFP_KERNEL);
hwxmits = pxmitpriv->hwxmits; hwxmits = pxmitpriv->hwxmits;

View File

@ -489,7 +489,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished)
struct rsvdpage_loc RsvdPageLoc; struct rsvdpage_loc RsvdPageLoc;
DBG_88E("%s\n", __func__); DBG_88E("%s\n", __func__);
ReservedPagePacket = (u8 *)rtw_zmalloc(1000); ReservedPagePacket = kzalloc(1000, GFP_KERNEL);
if (!ReservedPagePacket) { if (!ReservedPagePacket) {
DBG_88E("%s: alloc ReservedPagePacket fail!\n", __func__); DBG_88E("%s: alloc ReservedPagePacket fail!\n", __func__);
return; return;

View File

@ -76,13 +76,13 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf)
u16 efuse_utilized = 0; u16 efuse_utilized = 0;
u8 u1temp = 0; u8 u1temp = 0;
efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
if (!efuseTbl) { if (!efuseTbl) {
DBG_88E("%s: alloc efuseTbl fail!\n", __func__); DBG_88E("%s: alloc efuseTbl fail!\n", __func__);
goto exit; goto exit;
} }
eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); eFuseWord = rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
if (!eFuseWord) { if (!eFuseWord) {
DBG_88E("%s: alloc eFuseWord fail!\n", __func__); DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
goto exit; goto exit;
@ -790,13 +790,13 @@ static void Hal_EfuseReadEFuse88E(struct adapter *Adapter,
goto exit; goto exit;
} }
efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
if (!efuseTbl) { if (!efuseTbl) {
DBG_88E("%s: alloc efuseTbl fail!\n", __func__); DBG_88E("%s: alloc efuseTbl fail!\n", __func__);
goto exit; goto exit;
} }
eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); eFuseWord = rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
if (!eFuseWord) { if (!eFuseWord) {
DBG_88E("%s: alloc eFuseWord fail!\n", __func__); DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
goto exit; goto exit;

View File

@ -44,7 +44,8 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter)
/* init recv_buf */ /* init recv_buf */
_rtw_init_queue(&precvpriv->free_recv_buf_queue); _rtw_init_queue(&precvpriv->free_recv_buf_queue);
precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4); precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4,
GFP_KERNEL);
if (!precvpriv->pallocated_recv_buf) { if (!precvpriv->pallocated_recv_buf) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;

View File

@ -2230,7 +2230,7 @@ void rtl8188eu_set_hal_ops(struct adapter *adapt)
{ {
struct hal_ops *halfunc = &adapt->HalFunc; struct hal_ops *halfunc = &adapt->HalFunc;
adapt->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e)); adapt->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL);
if (!adapt->HalData) if (!adapt->HalData)
DBG_88E("cant not alloc memory for HAL DATA\n"); DBG_88E("cant not alloc memory for HAL DATA\n");
adapt->hal_data_sz = sizeof(struct hal_data_8188e); adapt->hal_data_sz = sizeof(struct hal_data_8188e);

View File

@ -215,15 +215,9 @@ extern unsigned char RSN_TKIP_CIPHER[4];
u8 *_rtw_vmalloc(u32 sz); u8 *_rtw_vmalloc(u32 sz);
u8 *_rtw_zvmalloc(u32 sz); u8 *_rtw_zvmalloc(u32 sz);
void _rtw_vmfree(u8 *pbuf, u32 sz); void _rtw_vmfree(u8 *pbuf, u32 sz);
u8 *_rtw_zmalloc(u32 sz);
u8 *_rtw_malloc(u32 sz);
void _rtw_mfree(u8 *pbuf, u32 sz);
#define rtw_vmalloc(sz) _rtw_vmalloc((sz)) #define rtw_vmalloc(sz) _rtw_vmalloc((sz))
#define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz))
#define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) #define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz))
#define rtw_malloc(sz) _rtw_malloc((sz))
#define rtw_zmalloc(sz) _rtw_zmalloc((sz))
#define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz))
void *rtw_malloc2d(int h, int w, int size); void *rtw_malloc2d(int h, int w, int size);

View File

@ -522,7 +522,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
if (wep_key_len > 0) { if (wep_key_len > 0) {
wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_key_len = wep_key_len <= 5 ? 5 : 13;
wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); pwep = kmalloc(wep_total_len, GFP_KERNEL);
if (!pwep) { if (!pwep) {
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n"));
goto exit; goto exit;
@ -642,7 +642,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
} }
if (ielen) { if (ielen) {
buf = rtw_zmalloc(ielen); buf = kzalloc(ielen, GFP_KERNEL);
if (!buf) { if (!buf) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit; goto exit;
@ -2109,11 +2109,9 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
int ret = 0; int ret = 0;
param_len = sizeof(struct ieee_param) + pext->key_len; param_len = sizeof(struct ieee_param) + pext->key_len;
param = (struct ieee_param *)rtw_malloc(param_len); param = kzalloc(param_len, GFP_KERNEL);
if (!param) if (!param)
return -1; return -ENOMEM;
memset(param, 0, param_len);
param->cmd = IEEE_CMD_SET_ENCRYPTION; param->cmd = IEEE_CMD_SET_ENCRYPTION;
memset(param->sta_addr, 0xff, ETH_ALEN); memset(param->sta_addr, 0xff, ETH_ALEN);
@ -2194,8 +2192,8 @@ static int rtw_wx_read32(struct net_device *dev,
padapter = (struct adapter *)rtw_netdev_priv(dev); padapter = (struct adapter *)rtw_netdev_priv(dev);
p = &wrqu->data; p = &wrqu->data;
len = p->length; len = p->length;
ptmp = (u8 *)rtw_malloc(len); ptmp = kmalloc(len, GFP_KERNEL);
if (NULL == ptmp) if (!ptmp)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(ptmp, p->pointer, len)) { if (copy_from_user(ptmp, p->pointer, len)) {
@ -2464,7 +2462,7 @@ static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info
pparmbuf = NULL; pparmbuf = NULL;
bset = (u8)(p->flags & 0xFFFF); bset = (u8)(p->flags & 0xFFFF);
len = p->length; len = p->length;
pparmbuf = (u8 *)rtw_malloc(len); pparmbuf = kmalloc(len, GFP_KERNEL);
if (!pparmbuf) { if (!pparmbuf) {
ret = -ENOMEM; ret = -ENOMEM;
goto _rtw_mp_ioctl_hdl_exit; goto _rtw_mp_ioctl_hdl_exit;
@ -4674,7 +4672,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
goto out; goto out;
} }
param = (struct ieee_param *)rtw_malloc(p->length); param = kmalloc(p->length, GFP_KERNEL);
if (!param) { if (!param) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
@ -4728,13 +4726,13 @@ static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta)
struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
u8 res = _SUCCESS; u8 res = _SUCCESS;
ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (!ph2c) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL);
if (!psetstakey_para) { if (!psetstakey_para) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;
@ -4766,12 +4764,12 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid)
DBG_88E("%s\n", __func__); DBG_88E("%s\n", __func__);
pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (!pcmd) { if (!pcmd) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
if (!psetkeyparm) { if (!psetkeyparm) {
kfree(pcmd); kfree(pcmd);
res = _FAIL; res = _FAIL;
@ -4887,14 +4885,11 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
if (wep_key_len > 0) { if (wep_key_len > 0) {
wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_key_len = wep_key_len <= 5 ? 5 : 13;
wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); pwep = kzalloc(wep_total_len, GFP_KERNEL);
if (!pwep) { if (!pwep) {
DBG_88E(" r871x_set_encryption: pwep allocate fail !!!\n"); ret = -ENOMEM;
goto exit; goto exit;
} }
memset(pwep, 0, wep_total_len);
pwep->KeyLength = wep_key_len; pwep->KeyLength = wep_key_len;
pwep->Length = wep_total_len; pwep->Length = wep_total_len;
} }
@ -5315,7 +5310,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param,
} }
if (ie_len > 0) { if (ie_len > 0) {
pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); pmlmepriv->wps_beacon_ie = kmalloc(ie_len, GFP_KERNEL);
pmlmepriv->wps_beacon_ie_len = ie_len; pmlmepriv->wps_beacon_ie_len = ie_len;
if (!pmlmepriv->wps_beacon_ie) { if (!pmlmepriv->wps_beacon_ie) {
DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__);
@ -5352,7 +5347,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par
} }
if (ie_len > 0) { if (ie_len > 0) {
pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); pmlmepriv->wps_probe_resp_ie = kmalloc(ie_len, GFP_KERNEL);
pmlmepriv->wps_probe_resp_ie_len = ie_len; pmlmepriv->wps_probe_resp_ie_len = ie_len;
if (!pmlmepriv->wps_probe_resp_ie) { if (!pmlmepriv->wps_probe_resp_ie) {
DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__);
@ -5384,11 +5379,11 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par
} }
if (ie_len > 0) { if (ie_len > 0) {
pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); pmlmepriv->wps_assoc_resp_ie = kmalloc(ie_len, GFP_KERNEL);
pmlmepriv->wps_assoc_resp_ie_len = ie_len; pmlmepriv->wps_assoc_resp_ie_len = ie_len;
if (!pmlmepriv->wps_assoc_resp_ie) { if (!pmlmepriv->wps_assoc_resp_ie) {
DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__);
return -EINVAL; return -ENOMEM;
} }
memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len); memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len);
@ -5491,7 +5486,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
goto out; goto out;
} }
param = (struct ieee_param *)rtw_malloc(p->length); param = kmalloc(p->length, GFP_KERNEL);
if (!param) { if (!param) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
@ -5600,9 +5595,8 @@ static int rtw_wx_set_priv(struct net_device *dev,
kfree(pmlmepriv->wps_probe_req_ie); kfree(pmlmepriv->wps_probe_req_ie);
pmlmepriv->wps_probe_req_ie = NULL; pmlmepriv->wps_probe_req_ie = NULL;
pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz); pmlmepriv->wps_probe_req_ie = kmalloc(cp_sz, GFP_KERNEL);
if (!pmlmepriv->wps_probe_req_ie) { if (!pmlmepriv->wps_probe_req_ie) {
pr_info("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__);
ret = -EINVAL; ret = -EINVAL;
goto FREE_EXT; goto FREE_EXT;
} }
@ -5674,12 +5668,12 @@ static int rtw_mp_efuse_get(struct net_device *dev,
pEfuseHal = &haldata->EfuseHal; pEfuseHal = &haldata->EfuseHal;
err = 0; err = 0;
data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); data = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL);
if (!data) { if (!data) {
err = -ENOMEM; err = -ENOMEM;
goto exit; goto exit;
} }
rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); rawdata = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL);
if (!rawdata) { if (!rawdata) {
err = -ENOMEM; err = -ENOMEM;
goto exit; goto exit;
@ -5989,22 +5983,22 @@ static int rtw_mp_efuse_set(struct net_device *dev,
haldata = GET_HAL_DATA(padapter); haldata = GET_HAL_DATA(padapter);
pEfuseHal = &haldata->EfuseHal; pEfuseHal = &haldata->EfuseHal;
err = 0; err = 0;
setdata = _rtw_zmalloc(1024); setdata = kzalloc(1024, GFP_KERNEL);
if (!setdata) { if (!setdata) {
err = -ENOMEM; err = -ENOMEM;
goto exit; goto exit;
} }
ShadowMapBT = _rtw_malloc(EFUSE_BT_MAX_MAP_LEN); ShadowMapBT = kmalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL);
if (!ShadowMapBT) { if (!ShadowMapBT) {
err = -ENOMEM; err = -ENOMEM;
goto exit; goto exit;
} }
ShadowMapWiFi = _rtw_malloc(EFUSE_MAP_SIZE); ShadowMapWiFi = kmalloc(EFUSE_MAP_SIZE, GFP_KERNEL);
if (!ShadowMapWiFi) { if (!ShadowMapWiFi) {
err = -ENOMEM; err = -ENOMEM;
goto exit; goto exit;
} }
setrawdata = _rtw_malloc(EFUSE_MAX_SIZE); setrawdata = kmalloc(EFUSE_MAX_SIZE, GFP_KERNEL);
if (!setrawdata) { if (!setrawdata) {
err = -ENOMEM; err = -ENOMEM;
goto exit; goto exit;
@ -7486,7 +7480,7 @@ static int rtw_test(
DBG_88E("+%s\n", __func__); DBG_88E("+%s\n", __func__);
len = wrqu->data.length; len = wrqu->data.length;
pbuf = (u8 *)rtw_zmalloc(len); pbuf = kzalloc(len, GFP_KERNEL);
if (!pbuf) { if (!pbuf) {
DBG_88E("%s: no memory!\n", __func__); DBG_88E("%s: no memory!\n", __func__);
return -ENOMEM; return -ENOMEM;
@ -7832,7 +7826,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
input_len = wdata.data.length; input_len = wdata.data.length;
if (input_len == 0) if (input_len == 0)
return -EFAULT; return -EFAULT;
input = rtw_zmalloc(input_len); input = kzalloc(input_len, GFP_KERNEL);
if (NULL == input) if (NULL == input)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(input, wdata.data.pointer, input_len)) { if (copy_from_user(input, wdata.data.pointer, input_len)) {
@ -7895,7 +7889,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
k = j; k = j;
} }
buffer = rtw_zmalloc(4096); buffer = kzalloc(4096, GFP_KERNEL);
if (NULL == buffer) { if (NULL == buffer) {
err = -ENOMEM; err = -ENOMEM;
goto exit; goto exit;
@ -8044,7 +8038,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
else else
n = wdata.data.length; n = wdata.data.length;
output = rtw_zmalloc(4096); output = kzalloc(4096, GFP_KERNEL);
if (NULL == output) { if (NULL == output) {
err = -ENOMEM; err = -ENOMEM;
goto exit; goto exit;

View File

@ -119,10 +119,9 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
if (authmode == _WPA_IE_ID_) { if (authmode == _WPA_IE_ID_) {
RT_TRACE(_module_mlme_osdep_c_, _drv_info_, RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
("rtw_report_sec_ie, authmode=%d\n", authmode)); ("rtw_report_sec_ie, authmode=%d\n", authmode));
buff = rtw_malloc(IW_CUSTOM_MAX); buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL);
if (!buff) if (!buff)
return; return;
memset(buff, 0, IW_CUSTOM_MAX);
p = buff; p = buff;
p += sprintf(p, "ASSOCINFO(ReqIEs ="); p += sprintf(p, "ASSOCINFO(ReqIEs =");
len = sec_ie[1]+2; len = sec_ie[1]+2;

View File

@ -58,32 +58,13 @@ inline void _rtw_vmfree(u8 *pbuf, u32 sz)
vfree(pbuf); vfree(pbuf);
} }
u8 *_rtw_malloc(u32 sz)
{
u8 *pbuf = NULL;
pbuf = kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
return pbuf;
}
u8 *_rtw_zmalloc(u32 sz)
{
u8 *pbuf = _rtw_malloc(sz);
if (pbuf)
memset(pbuf, 0, sz);
return pbuf;
}
void *rtw_malloc2d(int h, int w, int size) void *rtw_malloc2d(int h, int w, int size)
{ {
int j; int j;
void **a = (void **)rtw_zmalloc(h*sizeof(void *) + h*w*size); void **a = kzalloc(h * sizeof(void *) + h * w * size, GFP_KERNEL);
if (!a) { if (!a)
pr_info("%s: alloc memory fail!\n", __func__);
return NULL; return NULL;
}
for (j = 0; j < h; j++) for (j = 0; j < h; j++)
a[j] = ((char *)(a+h)) + j*w*size; a[j] = ((char *)(a+h)) + j*w*size;
@ -331,7 +312,7 @@ void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len)
goto keep_ori; goto keep_ori;
/* duplicate src */ /* duplicate src */
dup = rtw_malloc(src_len); dup = kmalloc(src_len, GFP_ATOMIC);
if (dup) { if (dup) {
dup_len = src_len; dup_len = src_len;
memcpy(dup, src, dup_len); memcpy(dup, src, dup_len);
@ -423,8 +404,7 @@ struct rtw_cbuf *rtw_cbuf_alloc(u32 size)
{ {
struct rtw_cbuf *cbuf; struct rtw_cbuf *cbuf;
cbuf = (struct rtw_cbuf *)rtw_malloc(sizeof(*cbuf) + cbuf = kmalloc(sizeof(*cbuf) + sizeof(void *)*size, GFP_KERNEL);
sizeof(void *)*size);
if (cbuf) { if (cbuf) {
cbuf->write = 0; cbuf->write = 0;

View File

@ -118,7 +118,7 @@ static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj)
_rtw_mutex_init(&dvobj->usb_vendor_req_mutex); _rtw_mutex_init(&dvobj->usb_vendor_req_mutex);
dvobj->usb_alloc_vendor_req_buf = rtw_zmalloc(MAX_USB_IO_CTL_SIZE); dvobj->usb_alloc_vendor_req_buf = kzalloc(MAX_USB_IO_CTL_SIZE, GFP_KERNEL);
if (!dvobj->usb_alloc_vendor_req_buf) { if (!dvobj->usb_alloc_vendor_req_buf) {
DBG_88E("alloc usb_vendor_req_buf failed... /n"); DBG_88E("alloc usb_vendor_req_buf failed... /n");
rst = _FAIL; rst = _FAIL;
@ -150,7 +150,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
struct usb_endpoint_descriptor *pendp_desc; struct usb_endpoint_descriptor *pendp_desc;
struct usb_device *pusbd; struct usb_device *pusbd;
pdvobjpriv = (struct dvobj_priv *)rtw_zmalloc(sizeof(*pdvobjpriv)); pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL);
if (!pdvobjpriv) if (!pdvobjpriv)
goto exit; goto exit;

View File

@ -76,7 +76,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
{ {
int i; int i;
pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL);
if (!pxmitbuf->pallocated_buf) if (!pxmitbuf->pallocated_buf)
return _FAIL; return _FAIL;