From 34ec2383872e3eabb32a94dd75d05477c4357c36 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 13:37:14 -0500 Subject: [PATCH] Remove wrapper around vfree This call is so simple that there is no need, or use, for a wrapper. Link: https://lore.kernel.org/r/20210805183717.23007-3-Larry.Finger@lwfinger.net --- core/efuse/rtw_efuse.c | 4 ++-- core/rtw_mlme.c | 3 +-- core/rtw_mp.c | 3 +-- core/rtw_recv.c | 3 +-- core/rtw_rf.c | 2 +- core/rtw_sta_mgt.c | 4 ++-- core/rtw_xmit.c | 13 +++++-------- hal/hal_com.c | 6 +++--- hal/hal_com_phycfg.c | 18 +++++++++--------- hal/hal_halmac.c | 2 +- hal/hal_intf.c | 2 +- hal/phydm/phydm_interface.c | 4 ++-- include/osdep_service.h | 5 ----- os_dep/linux/ioctl_linux.c | 8 ++++---- os_dep/linux/os_intfs.c | 4 ++-- os_dep/linux/usb_intf.c | 4 ++-- os_dep/osdep_service.c | 22 +--------------------- 17 files changed, 38 insertions(+), 69 deletions(-) diff --git a/core/efuse/rtw_efuse.c b/core/efuse/rtw_efuse.c index cca0261..309ecb3 100644 --- a/core/efuse/rtw_efuse.c +++ b/core/efuse/rtw_efuse.c @@ -3213,9 +3213,9 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf, int map_size) exit: if (file_data) - rtw_vmfree(file_data, file_size); + vfree(file_data); if (map) - rtw_vmfree(map, map_size); + vfree(map); return ret; } diff --git a/core/rtw_mlme.c b/core/rtw_mlme.c index 3922ff5..1588e49 100644 --- a/core/rtw_mlme.c +++ b/core/rtw_mlme.c @@ -307,8 +307,7 @@ void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) if (pmlmepriv) { rtw_mfree_mlme_priv_lock(pmlmepriv); - if (pmlmepriv->free_bss_buf) - rtw_vmfree(pmlmepriv->free_bss_buf, pmlmepriv->max_bss_cnt * sizeof(struct wlan_network)); + vfree(pmlmepriv->free_bss_buf); } exit: return; diff --git a/core/rtw_mp.c b/core/rtw_mp.c index cb0c057..7a95e64 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -2492,8 +2492,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_xmit_extbuf) - rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmit_extbuf); if (padapter->registrypriv.mp_mode == 0) { max_xmit_extbuf_size = 6000; diff --git a/core/rtw_recv.c b/core/rtw_recv.c index 24d6b5d..7443e0a 100644 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -194,8 +194,7 @@ void _rtw_free_recv_priv(struct recv_priv *precvpriv) rtw_os_recv_resource_free(precvpriv); - if (precvpriv->pallocated_frame_buf) - rtw_vmfree(precvpriv->pallocated_frame_buf, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); + vfree(precvpriv->pallocated_frame_buf); rtw_hal_free_recv_priv(padapter); diff --git a/core/rtw_rf.c b/core/rtw_rf.c index fa851e4..b74e2e5 100644 --- a/core/rtw_rf.c +++ b/core/rtw_rf.c @@ -1178,7 +1178,7 @@ void rtw_txpwr_lmt_list_free(struct rf_ctl_t *rfctl) if (ent->regd_name == rfctl->regd_name) rfctl->regd_name = regd_str(TXPWR_LMT_NONE); rtw_list_delete(&ent->list); - rtw_vmfree((u8 *)ent, sizeof(struct txpwr_lmt_ent) + strlen(ent->regd_name) + 1); + vfree(ent); } rfctl->txpwr_regd_num = 0; diff --git a/core/rtw_sta_mgt.c b/core/rtw_sta_mgt.c index f4fbdb4..5d05dc1 100644 --- a/core/rtw_sta_mgt.c +++ b/core/rtw_sta_mgt.c @@ -320,7 +320,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) exit: if (ret != _SUCCESS) { if (pstapriv->pallocated_stainfo_buf) - rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info) * NUM_STA + 4); + vfree(pstapriv->pallocated_stainfo_buf); #ifdef CONFIG_AP_MODE if (pstapriv->sta_aid) rtw_mfree(pstapriv->sta_aid, pstapriv->max_aid * sizeof(struct sta_info *)); @@ -471,7 +471,7 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) #endif if (pstapriv->pallocated_stainfo_buf) - rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info) * NUM_STA + 4); + vfree(pstapriv->pallocated_stainfo_buf); #ifdef CONFIG_AP_MODE if (pstapriv->sta_aid) rtw_mfree(pstapriv->sta_aid, pstapriv->max_aid * sizeof(struct sta_info *)); diff --git a/core/rtw_xmit.c b/core/rtw_xmit.c index 1b86e13..f88345d 100644 --- a/core/rtw_xmit.c +++ b/core/rtw_xmit.c @@ -405,12 +405,10 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_frame_buf) - rtw_vmfree(pxmitpriv->pallocated_frame_buf, NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + vfree(pxmitpriv->pallocated_frame_buf); - if (pxmitpriv->pallocated_xmitbuf) - rtw_vmfree(pxmitpriv->pallocated_xmitbuf, NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmitbuf); /* free xframe_ext queue, the same count as extbuf */ if ((pxmitframe = (struct xmit_frame *)pxmitpriv->xframe_ext)) { @@ -419,8 +417,8 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitframe++; } } - if (pxmitpriv->xframe_ext_alloc_addr) - rtw_vmfree(pxmitpriv->xframe_ext_alloc_addr, NR_XMIT_EXTBUFF * sizeof(struct xmit_frame) + 4); + + vfree(pxmitpriv->xframe_ext_alloc_addr); _rtw_spinlock_free(&pxmitpriv->free_xframe_ext_queue.lock); /* free xmit extension buff */ @@ -433,8 +431,7 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_xmit_extbuf) - rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmit_extbuf); for (i = 0; i < CMDBUF_MAX; i++) { pxmitbuf = &pxmitpriv->pcmd_xmitbuf[i]; diff --git a/hal/hal_com.c b/hal/hal_com.c index ea558a0..786d957 100644 --- a/hal/hal_com.c +++ b/hal/hal_com.c @@ -4702,7 +4702,7 @@ void rtw_dump_rsvd_page(void *sel, _adapter *adapter, u8 page_offset, u8 page_nu if (buffer) { rtw_hal_get_rsvd_page(adapter, page_offset, page_num, buffer, buf_size); RTW_DUMP_SEL(sel, buffer, buf_size); - rtw_vmfree(buffer, buf_size); + vfree(buffer); } else RTW_PRINT_SEL(sel, "ERROR - rsvd_buf mem allocate failed\n"); } else @@ -4739,7 +4739,7 @@ void rtw_dump_fifo(void *sel, _adapter *adapter, u8 fifo_sel, u32 fifo_addr, u32 if (buffer) { RTW_DUMP_SEL(sel, buffer, fifo_size); - rtw_vmfree(buffer, buff_size); + vfree(buffer); } RTW_PRINT_SEL(sel, "==========================\n"); @@ -5224,7 +5224,7 @@ static void rtw_hal_get_aoac_rpt(_adapter *adapter) _exit: if (buffer) - rtw_vmfree(buffer, buf_size); + vfree(buffer); } static void rtw_hal_update_tx_iv(_adapter *adapter) diff --git a/hal/hal_com_phycfg.c b/hal/hal_com_phycfg.c index ada38b2..7e68568 100644 --- a/hal/hal_com_phycfg.c +++ b/hal/hal_com_phycfg.c @@ -5359,43 +5359,43 @@ void phy_free_filebuf_mask(_adapter *padapter, u8 mask) HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); if (pHalData->mac_reg && (mask & LOAD_MAC_PARA_FILE)) { - rtw_vmfree(pHalData->mac_reg, pHalData->mac_reg_len); + vfree(pHalData->mac_reg); pHalData->mac_reg = NULL; } if (mask & LOAD_BB_PARA_FILE) { if (pHalData->bb_phy_reg) { - rtw_vmfree(pHalData->bb_phy_reg, pHalData->bb_phy_reg_len); + vfree(pHalData->bb_phy_reg); pHalData->bb_phy_reg = NULL; } if (pHalData->bb_agc_tab) { - rtw_vmfree(pHalData->bb_agc_tab, pHalData->bb_agc_tab_len); + vfree(pHalData->bb_agc_tab); pHalData->bb_agc_tab = NULL; } } if (pHalData->bb_phy_reg_pg && (mask & LOAD_BB_PG_PARA_FILE)) { - rtw_vmfree(pHalData->bb_phy_reg_pg, pHalData->bb_phy_reg_pg_len); + vfree(pHalData->bb_phy_reg_pg); pHalData->bb_phy_reg_pg = NULL; } if (pHalData->bb_phy_reg_mp && (mask & LOAD_BB_MP_PARA_FILE)) { - rtw_vmfree(pHalData->bb_phy_reg_mp, pHalData->bb_phy_reg_mp_len); + vfree(pHalData->bb_phy_reg_mp); pHalData->bb_phy_reg_mp = NULL; } if (mask & LOAD_RF_PARA_FILE) { if (pHalData->rf_radio_a) { - rtw_vmfree(pHalData->rf_radio_a, pHalData->rf_radio_a_len); + vfree(pHalData->rf_radio_a); pHalData->rf_radio_a = NULL; } if (pHalData->rf_radio_b) { - rtw_vmfree(pHalData->rf_radio_b, pHalData->rf_radio_b_len); + vfree(pHalData->rf_radio_b); pHalData->rf_radio_b = NULL; } } if (pHalData->rf_tx_pwr_track && (mask & LOAD_RF_TXPWR_TRACK_PARA_FILE)) { - rtw_vmfree(pHalData->rf_tx_pwr_track, pHalData->rf_tx_pwr_track_len); + vfree(pHalData->rf_tx_pwr_track); pHalData->rf_tx_pwr_track = NULL; } if (pHalData->rf_tx_pwr_lmt && (mask & LOAD_RF_TXPWR_LMT_PARA_FILE)) { - rtw_vmfree(pHalData->rf_tx_pwr_lmt, pHalData->rf_tx_pwr_lmt_len); + vfree(pHalData->rf_tx_pwr_lmt); pHalData->rf_tx_pwr_lmt = NULL; } } diff --git a/hal/hal_halmac.c b/hal/hal_halmac.c index 0b74ecb..a12abab 100644 --- a/hal/hal_halmac.c +++ b/hal/hal_halmac.c @@ -4414,7 +4414,7 @@ int rtw_halmac_dump_fifo(struct dvobj_priv *d, u8 fifo_sel, u32 addr, u32 size, _exit: if ((mem_created == _TRUE) && pfifo_map) - rtw_vmfree(pfifo_map, fifo_size); + vfree(pfifo_map); return ret; } diff --git a/hal/hal_intf.c b/hal/hal_intf.c index 25edef6..665d8e8 100644 --- a/hal/hal_intf.c +++ b/hal/hal_intf.c @@ -164,7 +164,7 @@ void rtw_hal_data_deinit(_adapter *padapter) #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE phy_free_filebuf(padapter); #endif - rtw_vmfree(padapter->HalData, padapter->hal_data_sz); + vfree(padapter->HalData); padapter->HalData = NULL; padapter->hal_data_sz = 0; } diff --git a/hal/phydm/phydm_interface.c b/hal/phydm/phydm_interface.c index fe0f5c2..7fb1a25 100644 --- a/hal/phydm/phydm_interface.c +++ b/hal/phydm/phydm_interface.c @@ -389,12 +389,12 @@ void odm_free_memory(struct dm_struct *dm, void *ptr, u32 length) #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2) kfree(ptr); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) - rtw_vmfree(ptr, length); + vfree(ptr); #elif (DM_ODM_SUPPORT_TYPE & ODM_WIN) /* struct void* adapter = dm->adapter; */ PlatformFreeMemory(ptr, length); #elif (DM_ODM_SUPPORT_TYPE & ODM_IOT) - rtw_vmfree(ptr, length); + vfree(ptr); #endif } diff --git a/include/osdep_service.h b/include/osdep_service.h index d26cd9f..749189b 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -170,14 +170,12 @@ void dbg_rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dm #ifdef CONFIG_USE_VMALLOC #define rtw_vmalloc(sz) dbg_rtw_vmalloc((sz), MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_zvmalloc(sz) dbg_rtw_zvmalloc((sz), MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) -#define rtw_vmfree(pbuf, sz) dbg_rtw_vmfree((pbuf), (sz), MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_vmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zvmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_vmfree_f(pbuf, sz, mstat_f) dbg_rtw_vmfree((pbuf), (sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #else /* CONFIG_USE_VMALLOC */ #define rtw_vmalloc(sz) dbg_rtw_malloc((sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_zvmalloc(sz) dbg_rtw_zmalloc((sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) -#define rtw_vmfree(pbuf, sz) dbg_rtw_mfree((pbuf), (sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_malloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_vmfree_f(pbuf, sz, mstat_f) dbg_rtw_mfree((pbuf), (sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) @@ -218,7 +216,6 @@ void dbg_rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dm #define match_mstat_sniff_rules(flags, size) _FALSE void *_rtw_vmalloc(u32 sz); void *_rtw_zvmalloc(u32 sz); -void _rtw_vmfree(void *pbuf, u32 sz); void *_rtw_zmalloc(u32 sz); void *_rtw_malloc(u32 sz); void _rtw_mfree(void *pbuf, u32 sz); @@ -244,14 +241,12 @@ void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_a #ifdef CONFIG_USE_VMALLOC #define rtw_vmalloc(sz) _rtw_vmalloc((sz)) #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) -#define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) #define rtw_vmalloc_f(sz, mstat_f) _rtw_vmalloc((sz)) #define rtw_zvmalloc_f(sz, mstat_f) _rtw_zvmalloc((sz)) #define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_vmfree((pbuf), (sz)) #else /* CONFIG_USE_VMALLOC */ #define rtw_vmalloc(sz) _rtw_malloc((sz)) #define rtw_zvmalloc(sz) _rtw_zmalloc((sz)) -#define rtw_vmfree(pbuf, sz) _rtw_mfree((pbuf), (sz)) #define rtw_vmalloc_f(sz, mstat_f) _rtw_malloc((sz)) #define rtw_zvmalloc_f(sz, mstat_f) _rtw_zmalloc((sz)) #define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_mfree((pbuf), (sz)) diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index 372deef..3aca931 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -7875,7 +7875,7 @@ static int rtw_wx_set_priv(struct net_device *dev, return -ENOMEM; if (copy_from_user(ext, dwrq->pointer, len)) { - rtw_vmfree(ext, len); + vfree(ext); return -EFAULT; } @@ -7884,7 +7884,7 @@ static int rtw_wx_set_priv(struct net_device *dev, #ifdef CONFIG_DEBUG_RTW_WX_SET_PRIV ext_dbg = rtw_vmalloc(len); if (!ext_dbg) { - rtw_vmfree(ext, len); + vfree(ext); return -ENOMEM; } @@ -8004,9 +8004,9 @@ static int rtw_wx_set_priv(struct net_device *dev, FREE_EXT: - rtw_vmfree(ext, len); + vfree(ext); #ifdef CONFIG_DEBUG_RTW_WX_SET_PRIV - rtw_vmfree(ext_dbg, len); + vfree(ext_dbg); #endif /* RTW_INFO("rtw_wx_set_priv: (SIOCSIWPRIV) %s ret=%d\n", */ diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 9356a7c..ec2e00a 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -2898,7 +2898,7 @@ free_drv_sw: rtw_free_drv_sw(padapter); free_adapter: if (res != _SUCCESS && padapter) { - rtw_vmfree((u8 *)padapter, sizeof(*padapter)); + vfree((u8 *)padapter); padapter = NULL; } exit: @@ -2958,7 +2958,7 @@ void rtw_drv_free_vir_if(_adapter *padapter) /* TODO: use rtw_os_ndevs_deinit instead at the first stage of driver's dev deinit function */ rtw_os_ndev_free(padapter); - rtw_vmfree((u8 *)padapter, sizeof(_adapter)); + vfree(padapter); } diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index bbcfde1..0e9c628 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -1399,7 +1399,7 @@ free_adapter: #ifdef RTW_HALMAC rtw_halmac_deinit_adapter(dvobj); #endif - rtw_vmfree((u8 *)padapter, sizeof(*padapter)); + vfree((u8 *)padapter); padapter = NULL; } exit: @@ -1459,7 +1459,7 @@ static void rtw_usb_primary_adapter_deinit(_adapter *padapter) rtw_halmac_deinit_adapter(adapter_to_dvobj(padapter)); #endif /* RTW_HALMAC */ - rtw_vmfree((u8 *)padapter, sizeof(_adapter)); + vfree(padapter); #ifdef CONFIG_PLATFORM_RTD2880B RTW_INFO("wlan link down\n"); diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 3dc89ca..73703ba 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -111,26 +111,6 @@ inline void *_rtw_zvmalloc(u32 sz) return pbuf; } -inline void _rtw_vmfree(void *pbuf, u32 sz) -{ -#ifdef PLATFORM_LINUX - vfree(pbuf); -#endif -#ifdef PLATFORM_FREEBSD - free(pbuf, M_DEVBUF); -#endif -#ifdef PLATFORM_WINDOWS - NdisFreeMemory(pbuf, sz, 0); -#endif - -#ifdef DBG_MEMORY_LEAK -#ifdef PLATFORM_LINUX - atomic_dec(&_malloc_cnt); - atomic_sub(sz, &_malloc_size); -#endif -#endif /* DBG_MEMORY_LEAK */ -} - void *_rtw_malloc(u32 sz) { void *pbuf = NULL; @@ -602,7 +582,7 @@ inline void dbg_rtw_vmfree(void *pbuf, u32 sz, const enum mstat_f flags, const c if (match_mstat_sniff_rules(flags, sz)) RTW_INFO("DBG_MEM_ALLOC %s:%d %s(%d)\n", func, line, __FUNCTION__, (sz)); - _rtw_vmfree((pbuf), (sz)); + vfree((pbuf)); rtw_mstat_update( flags