staging: r8188eu: cleanup unset pointers in
cover staging: r8188eu: cleanup unset pointers in
This series removes all remaining pointers from struct hal_ops that are never set anywhere else in the driver. As a part of this, it also takes out the wrapper functions and their callers, given that they mostly never end up calling/returning the function pointer value as they check for NULL.
There are two exceptions to this however, and therefore this series also fixes two potentially triggerable NULL pointer dereference bugs.
Phillip Potter (14):
staging: r8188eu: remove rtw_hal_reset_security_engine function
staging: r8188eu: remove hal_reset_security_engine from struct hal_ops
staging: r8188eu: remove rtw_hal_enable_interrupt function
staging: r8188eu: remove enable_interrupt from struct hal_ops
staging: r8188eu: remove rtw_hal_disable_interrupt function
staging: r8188eu: remove disable_interrupt from struct hal_ops
staging: r8188eu: remove rtw_hal_interrupt_handler function
staging: r8188eu: remove interrupt_handler from struct hal_ops
staging: r8188eu: remove rtw_hal_xmitframe_enqueue function
staging: r8188eu: remove hal_xmitframe_enqueue from struct hal_ops
staging: r8188eu: remove Efuse_PgPacketWrite_BT function
staging: r8188eu: remove Efuse_PgPacketWrite_BT from struct hal_ops
staging: r8188eu: remove rtw_hal_c2h_id_filter_ccx function
staging: r8188eu: remove c2h_id_filter_ccx from struct hal_ops
drivers/staging/r8188eu/core/rtw_cmd.c | 9 +---- drivers/staging/r8188eu/core/rtw_efuse.c | 13 +------ drivers/staging/r8188eu/core/rtw_recv.c | 2 - drivers/staging/r8188eu/hal/hal_intf.c | 44 ---------------------- drivers/staging/r8188eu/include/hal_intf.h | 19 ---------- 5 files changed, 3 insertions(+), 84 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/14 staging: r8188eu: remove rtw_hal_reset_security_engine function
Remove rtw_hal_reset_security_engine and its one caller from hal/hal_intf.c, and remove its declaration from include/hal_intf.h as well. This is just a wrapper function that calls the function pointer hal_reset_security_engine in struct hal_ops if it is set, which it never is.
--- drivers/staging/r8188eu/hal/hal_intf.c | 8 -------- drivers/staging/r8188eu/include/hal_intf.h | 1 - 2 files changed, 9 deletions(-)
drivers/staging/r8188eu/hal/hal_intf.c +0 -8
@@ -81,8 +81,6 @@ uint rtw_hal_init(struct adapter *adapt)if (adapt->registrypriv.notch_filter ==1 )rtw_hal_notch_filter (adapt,1 ); - -rtw_hal_reset_security_engine (adapt); }else { adapt->hw_init_completed = false;DBG_88E ("rtw_hal_init: hal__init fail\n" );
@@ -420,12 +418,6 @@ void rtw_hal_notch_filter(struct adapter *adapter, bool enable) adapter->HalFunc.hal_notch_filter (adapter, enable); } -void rtw_hal_reset_security_engine (struct adapter *adapter) -{ -if (adapter->HalFunc.hal_reset_security_engine) - adapter->HalFunc.hal_reset_security_engine (adapter); -} -c2h_id_filter rtw_hal_c2h_id_filter_ccx (struct adapter *adapter) {return adapter->HalFunc.c2h_id_filter_ccx;
drivers/staging/r8188eu/include/hal_intf.h +0 -1
@@ -360,7 +360,6 @@ int rtw_hal_iol_cmd(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt);void rtw_hal_notch_filter (struct adapter *adapter,bool enable); -void rtw_hal_reset_security_engine (struct adapter *adapter);c2h_id_filter rtw_hal_c2h_id_filter_ccx (struct adapter *adapter);void indicate_wx_scan_complete_event (struct adapter *padapter);
Signature · 1 line
2.31.1
PATCH 2/14 staging: r8188eu: remove hal_reset_security_engine from struct hal_ops
In reply to Phillip PotterRemove hal_reset_security_engine function pointer from struct hal_ops, as it is unused.
--- drivers/staging/r8188eu/include/hal_intf.h | 1 - 1 file changed, 1 deletion(-)
drivers/staging/r8188eu/include/hal_intf.h +0 -1
@@ -250,7 +250,6 @@ struct hal_ops { u32 bndy_cnt);void (*hal_notch_filter)(struct adapter *adapter,bool enable); -void (*hal_reset_security_engine)(struct adapter *adapter);c2h_id_filter c2h_id_filter_ccx; };
Signature · 1 line
2.31.1
Re: [PATCH 02/14] staging: r8188eu: remove hal_reset_security_engine from struct hal_ops
Quoted 13 lines · Phillip Potter
Remove
hal_reset_security_enginefunction pointer from structhal_ops, as it is unused.Signed-off-by Phillip Potter <[email protected]>--- drivers/staging/r8188eu/include/hal_intf.h | 1 - 1 file changed, 1 deletion(-)drivers/staging/r8188eu/include/hal_intf.h +0
-0
drivers/staging/r8188eu/include/hal_intf.h struct hal_ops { · line 254
Quoted 6 lines
drivers/staging/r8188eu/include/hal_intf.h +0
-1@@ -250,7 +250,6 @@ struct hal_ops { u32 bndy_cnt);void (*hal_notch_filter)(struct adapter *adapter,bool enable); -void (*hal_reset_security_engine)(struct adapter *adapter);c2h_id_filter c2h_id_filter_ccx; };
I love these patchsets which are removing the HAL layer, but it would be better if you folded patches 1 and 2 together because it would be easier to review. That way we can just say "Well, if this patch isn't correct it will cause a compile error so let's assume it's correct unless the kbuild-bot complains."
There are other pairs in this patchset which are the same way where they would be easier to review if they were merged. 3 & 4. 5 & 6. Etc.
The patcheset is fine but for future reference please fold them together.
regards,
dan carpenter
Re: [PATCH 02/14] staging: r8188eu: remove hal_reset_security_engine from struct hal_ops
Quoted 31 lines · Dan Carpenter
Quoted 13 lines · Phillip Potter
Remove
hal_reset_security_enginefunction pointer from structhal_ops, as it is unused.Signed-off-by Phillip Potter <[email protected]>--- drivers/staging/r8188eu/include/hal_intf.h | 1 - 1 file changed, 1 deletion(-)drivers/staging/r8188eu/include/hal_intf.h +0
-0drivers/staging/r8188eu/include/hal_intf.h struct hal_ops { · line 254
Quoted 6 lines
drivers/staging/r8188eu/include/hal_intf.h +0
-1@@ -250,7 +250,6 @@ struct hal_ops { u32 bndy_cnt);void (*hal_notch_filter)(struct adapter *adapter,bool enable); -void (*hal_reset_security_engine)(struct adapter *adapter);c2h_id_filter c2h_id_filter_ccx; };I love these patchsets which are removing the HAL layer, but it would be better if you folded patches 1 and 2 together because it would be easier to review. That way we can just say "Well, if this patch isn't correct it will cause a compile error so let's assume it's correct unless the kbuild-bot complains."
There are other pairs in this patchset which are the same way where they would be easier to review if they were merged. 3 & 4. 5 & 6. Etc.
Quoted 7 lines
The patcheset is fine but for future reference please fold them together.
Reviewed-by Dan Carpenter <[email protected]>regards,
dan carpenter
Dear Dan,
Thank you for the review, much appreciated. I will endeavour to do this in future.
Regards,
Phil
PATCH 3/14 staging: r8188eu: remove rtw_hal_enable_interrupt function
In reply to Phillip PotterRemove rtw_hal_enable_interrupt from hal/hal_intf.c, and remove its declaration from include/hal_intf.h as well. This is just a wrapper function that calls the function pointer enable_interrupt in struct hal_ops if it is set, which it never is. In addition, this wrapper function is unused anyway.
--- drivers/staging/r8188eu/hal/hal_intf.c | 8 -------- drivers/staging/r8188eu/include/hal_intf.h | 1 - 2 files changed, 9 deletions(-)
drivers/staging/r8188eu/hal/hal_intf.c +0 -8
@@ -149,14 +149,6 @@ void rtw_hal_get_odm_var(struct adapter *adapt, val1, set); } -void rtw_hal_enable_interrupt (struct adapter *adapt) -{ -if (adapt->HalFunc.enable_interrupt) - adapt->HalFunc.enable_interrupt (adapt); -else -DBG_88E ("%s: HalFunc.enable_interrupt is NULL!\n" , __func__); -} -void rtw_hal_disable_interrupt (struct adapter *adapt) {if (adapt->HalFunc.disable_interrupt)
drivers/staging/r8188eu/include/hal_intf.h +0 -1
@@ -298,7 +298,6 @@ void rtw_hal_get_odm_var(struct adapter *padapter,enum hal_odm_variable eVariable, void *pValue1, bool bSet); -void rtw_hal_enable_interrupt (struct adapter *padapter);void rtw_hal_disable_interrupt (struct adapter *padapter);u32 rtw_hal_inirp_init (struct adapter *padapter);
Signature · 1 line
2.31.1
PATCH 4/14 staging: r8188eu: remove enable_interrupt from struct hal_ops
In reply to Phillip PotterRemove enable_interrupt function pointer from struct hal_ops, as it is unused.
--- drivers/staging/r8188eu/include/hal_intf.h | 1 - 1 file changed, 1 deletion(-)
drivers/staging/r8188eu/include/hal_intf.h +0 -1
@@ -156,7 +156,6 @@ struct hal_ops {void (*read_adapter_info)(struct adapter *padapter); -void (*enable_interrupt)(struct adapter *padapter);void (*disable_interrupt)(struct adapter *padapter);s32 (*interrupt_handler)(struct adapter *padapter);
Signature · 1 line
2.31.1
PATCH 5/14 staging: r8188eu: remove rtw_hal_disable_interrupt function
In reply to Phillip PotterRemove rtw_hal_disable_interrupt from hal/hal_intf.c, and remove its declaration from include/hal_intf.h as well. This is just a wrapper function that calls the function pointer disable_interrupt in struct hal_ops if it is set, which it never is. In addition, this wrapper function is unused anyway.
--- drivers/staging/r8188eu/hal/hal_intf.c | 8 -------- drivers/staging/r8188eu/include/hal_intf.h | 2 -- 2 files changed, 10 deletions(-)
drivers/staging/r8188eu/hal/hal_intf.c +0 -8
@@ -149,14 +149,6 @@ void rtw_hal_get_odm_var(struct adapter *adapt, val1, set); } -void rtw_hal_disable_interrupt (struct adapter *adapt) -{ -if (adapt->HalFunc.disable_interrupt) - adapt->HalFunc.disable_interrupt (adapt); -else -DBG_88E ("%s: HalFunc.disable_interrupt is NULL!\n" , __func__); -} -u32 rtw_hal_inirp_init (struct adapter *adapt) {u32 rst = _FAIL;
drivers/staging/r8188eu/include/hal_intf.h +0 -2
@@ -297,8 +297,6 @@ void rtw_hal_get_odm_var(struct adapter *padapter,enum hal_odm_variable eVariable, void *pValue1, bool bSet); -void rtw_hal_disable_interrupt (struct adapter *padapter); -u32 rtw_hal_inirp_init (struct adapter *padapter);u32 rtw_hal_inirp_deinit (struct adapter *padapter);
Signature · 1 line
2.31.1
PATCH 6/14 staging: r8188eu: remove disable_interrupt from struct hal_ops
In reply to Phillip PotterRemove disable_interrupt function pointer from struct hal_ops, as it is unused.
--- drivers/staging/r8188eu/include/hal_intf.h | 1 - 1 file changed, 1 deletion(-)
drivers/staging/r8188eu/include/hal_intf.h +0 -1
@@ -156,7 +156,6 @@ struct hal_ops {void (*read_adapter_info)(struct adapter *padapter); -void (*disable_interrupt)(struct adapter *padapter);s32 (*interrupt_handler)(struct adapter *padapter); void (*set_bwmode_handler)(struct adapter *padapter,
Signature · 1 line
2.31.1
PATCH 7/14 staging: r8188eu: remove rtw_hal_interrupt_handler function
In reply to Phillip PotterRemove rtw_hal_interrupt_handler from hal/hal_intf.c, and remove its declaration from include/hal_intf.h as well. This is just a wrapper function that calls the function pointer interrupt_handler in struct hal_ops if it is set, which it never is. In addition, this wrapper function is unused anyway.
--- drivers/staging/r8188eu/hal/hal_intf.c | 7 ------- drivers/staging/r8188eu/include/hal_intf.h | 2 -- 2 files changed, 9 deletions(-)
drivers/staging/r8188eu/hal/hal_intf.c +0 -7
@@ -299,13 +299,6 @@ void rtw_hal_write_rfreg(struct adapter *adapt, enum rf_radio_path rfpath, bitmask, data); } -s32 rtw_hal_interrupt_handler (struct adapter *adapt) -{ -if (adapt->HalFunc.interrupt_handler) -return adapt->HalFunc.interrupt_handler (adapt); -return _FAIL; -} -void rtw_hal_set_bwmode (struct adapter *adapt,enum ht_channel_width bandwidth,u8 offset) {
drivers/staging/r8188eu/include/hal_intf.h +0 -2
@@ -331,8 +331,6 @@ void rtw_hal_write_rfreg(struct adapter *padapter, enum rf_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data); -s32 rtw_hal_interrupt_handler (struct adapter *padapter); -void rtw_hal_set_bwmode (struct adapter *padapter,enum ht_channel_width Bandwidth,u8 Offset);void rtw_hal_set_chan (struct adapter *padapter,u8 channel);
Signature · 1 line
2.31.1
PATCH 8/14 staging: r8188eu: remove interrupt_handler from struct hal_ops
In reply to Phillip PotterRemove interrupt_handler function pointer from struct hal_ops, as it is unused.
--- drivers/staging/r8188eu/include/hal_intf.h | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/r8188eu/include/hal_intf.h +0 -2
@@ -156,8 +156,6 @@ struct hal_ops {void (*read_adapter_info)(struct adapter *padapter); -s32 (*interrupt_handler)(struct adapter *padapter); -void (*set_bwmode_handler)(struct adapter *padapter,enum ht_channel_width Bandwidth,u8 Offset);
Signature · 1 line
2.31.1
PATCH 9/14 staging: r8188eu: remove rtw_hal_xmitframe_enqueue function
In reply to Phillip PotterRemove rtw_hal_xmitframe_enqueue from hal/hal_intf.c and its one caller from core/rtw_recv.c, and remove its declaration from include/hal_intf.h as well. This is just a wrapper function that calls the function pointer hal_xmitframe_enqueue in struct hal_ops if it is set, which it never is.
--- drivers/staging/r8188eu/core/rtw_recv.c | 2 -- drivers/staging/r8188eu/hal/hal_intf.c | 8 -------- drivers/staging/r8188eu/include/hal_intf.h | 2 -- 3 files changed, 12 deletions(-)
drivers/staging/r8188eu/core/rtw_recv.c +0 -2
@@ -966,8 +966,6 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, pxmitframe->attrib.triggered =1 ; -rtw_hal_xmitframe_enqueue (padapter, pxmitframe); -if (psta->sleepq_len ==0 ) { pstapriv->tim_bitmap &= ~BIT (psta->aid);
drivers/staging/r8188eu/hal/hal_intf.c +0 -8
@@ -177,14 +177,6 @@ u8 rtw_hal_intf_ps_func(struct adapter *adapt,return _FAIL; } -s32 rtw_hal_xmitframe_enqueue (struct adapter *padapter, -struct xmit_frame *pxmitframe) -{ -if (padapter->HalFunc.hal_xmitframe_enqueue) -return padapter->HalFunc.hal_xmitframe_enqueue (padapter, pxmitframe); -return false; -} -s32 rtw_hal_xmit (struct adapter *adapt,struct xmit_frame *pxmitframe) {if (adapt->HalFunc.hal_xmit)
drivers/staging/r8188eu/include/hal_intf.h +0 -2
@@ -299,8 +299,6 @@ u32 rtw_hal_inirp_deinit(struct adapter *padapter);u8 rtw_hal_intf_ps_func (struct adapter *padapter,enum hal_intf_ps_func efunc_id,u8 *val); -s32 rtw_hal_xmitframe_enqueue (struct adapter *padapter, -struct xmit_frame *pxmitframe);s32 rtw_hal_xmit (struct adapter *padapter,struct xmit_frame *pxmitframe); s32 rtw_hal_mgnt_xmit(struct adapter *padapter,
Signature · 1 line
2.31.1
PATCH 10/14 staging: r8188eu: remove hal_xmitframe_enqueue from struct hal_ops
In reply to Phillip PotterRemove hal_xmitframe_enqueue function pointer from struct hal_ops, as it is unused.
--- drivers/staging/r8188eu/include/hal_intf.h | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/r8188eu/include/hal_intf.h +0 -2
@@ -202,8 +202,6 @@ struct hal_ops { struct xmit_frame *pxmitframe);s32 (*mgnt_xmit)(struct adapter *padapter,struct xmit_frame *pmgntframe); -s32 (*hal_xmitframe_enqueue)(struct adapter *padapter, -struct xmit_frame *pxmitframe);u32 (*read_bbreg)(struct adapter *padapter,u32 RegAddr,u32 BitMask);
Signature · 1 line
2.31.1
PATCH 11/14 staging: r8188eu: remove Efuse_PgPacketWrite_BT function
In reply to Phillip PotterRemove static Efuse_PgPacketWrite_BT and its one caller from core/rtw_efuse.c. This function is a wrapper function which calls the Efuse_PgPacketWrite_BT function pointer of struct hal_ops unconditionally. As this function pointer is never set, and this function call is possible to reach, this could lead to an attempt to deference a NULL pointer, which would crash the driver.
--- drivers/staging/r8188eu/core/rtw_efuse.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/staging/r8188eu/core/rtw_efuse.c +1 -12
@@ -351,15 +351,6 @@ int Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *datreturn ret; } -static int Efuse_PgPacketWrite_BT (struct adapter *pAdapter,u8 offset,u8 word_en,u8 *data,bool pseudo) -{ -int ret; - - ret = pAdapter->HalFunc.Efuse_PgPacketWrite_BT (pAdapter, offset, word_en, data, pseudo); - -return ret; -} -/*----------------------------------------------------------------------------- * Function: efuse_WordEnableDataRead *
@@ -676,9 +667,7 @@ u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *dataDBG_88E ("0x%02X " , newdata[i]);DBG_88E ("\n" ); - ret =Efuse_PgPacketWrite_BT (padapter, offset, word_en, newdata, false); -if (ret == _FAIL) -break ; +break ; }if (idx == cnts)
Signature · 1 line
2.31.1
PATCH 12/14 staging: r8188eu: remove Efuse_PgPacketWrite_BT from struct hal_ops
In reply to Phillip PotterRemove Efuse_PgPacketWrite_BT function pointer from struct hal_ops, as it is unused.
--- drivers/staging/r8188eu/include/hal_intf.h | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/r8188eu/include/hal_intf.h +0 -2
@@ -229,8 +229,6 @@ struct hal_ops {u8 (*Efuse_WordEnableDataWrite)(struct adapter *padapter,u16 efuse_addr,u8 word_en,u8 *data,bool bPseudoTest); -bool (*Efuse_PgPacketWrite_BT)(struct adapter *padapter,u8 offset, -u8 word_en,u8 *data,bool test);void (*sreset_init_value)(struct adapter *padapter);void (*sreset_reset_value)(struct adapter *padapter);
Signature · 1 line
2.31.1
PATCH 13/14 staging: r8188eu: remove rtw_hal_c2h_id_filter_ccx function
In reply to Phillip PotterRemove rtw_hal_c2h_id_filter_ccx from hal/hal_intf.c and its one caller from core/rtw_cmd.c. This function is a wrapper function which returns the c2h_id_filter_ccx function pointer of struct hal_ops unconditionally. As this function pointer is never set, and the function call's return value is subsequently called inside an if condition, this could lead to an attempt to deference a NULL pointer, which would crash the driver.
--- drivers/staging/r8188eu/core/rtw_cmd.c | 9 ++------- drivers/staging/r8188eu/hal/hal_intf.c | 5 ----- drivers/staging/r8188eu/include/hal_intf.h | 1 - 3 files changed, 2 insertions(+), 13 deletions(-)
drivers/staging/r8188eu/core/rtw_cmd.c +2 -7
@@ -1865,7 +1865,6 @@ static void c2h_wk_callback(struct work_struct *work) struct evt_priv *evtpriv = container_of(work, struct evt_priv, c2h_wk); struct adapter *adapter = container_of(evtpriv, struct adapter, evtpriv);struct c2h_evt_hdr *c2h_evt; -c2h_id_filter ccx_id_filter =rtw_hal_c2h_id_filter_ccx (adapter); evtpriv->c2h_wk_alive = true;
@@ -1895,14 +1894,10 @@ static void c2h_wk_callback(struct work_struct *work)continue ; } -if (ccx_id_filter (c2h_evt->id)) { -kfree (c2h_evt); - }else {#ifdef CONFIG_88EU_P2P -/* Enqueue into cmd_thread for others */ -rtw_c2h_wk_cmd (adapter, (u8 *)c2h_evt); +/* Enqueue into cmd_thread for others */ +rtw_c2h_wk_cmd (adapter, (u8 *)c2h_evt);#endif - } } evtpriv->c2h_wk_alive = false;
drivers/staging/r8188eu/hal/hal_intf.c +0 -5
@@ -386,8 +386,3 @@ void rtw_hal_notch_filter(struct adapter *adapter, bool enable)if (adapter->HalFunc.hal_notch_filter) adapter->HalFunc.hal_notch_filter (adapter, enable); } - -c2h_id_filter rtw_hal_c2h_id_filter_ccx (struct adapter *adapter) -{ -return adapter->HalFunc.c2h_id_filter_ccx; -}
drivers/staging/r8188eu/include/hal_intf.h +0 -1
@@ -345,7 +345,6 @@ int rtw_hal_iol_cmd(struct adapter *adapter, struct xmit_frame *xmit_frame,void rtw_hal_notch_filter (struct adapter *adapter,bool enable); -c2h_id_filter rtw_hal_c2h_id_filter_ccx (struct adapter *adapter);void indicate_wx_scan_complete_event (struct adapter *padapter);u8 rtw_do_join (struct adapter *padapter);
Signature · 1 line
2.31.1
PATCH 14/14 staging: r8188eu: remove c2h_id_filter_ccx from struct hal_ops
In reply to Phillip PotterRemove c2h_id_filter_ccx function pointer from struct hal_ops, as it is unused.
--- drivers/staging/r8188eu/include/hal_intf.h | 1 - 1 file changed, 1 deletion(-)
drivers/staging/r8188eu/include/hal_intf.h +0 -1
@@ -242,7 +242,6 @@ struct hal_ops { u32 bndy_cnt);void (*hal_notch_filter)(struct adapter *adapter,bool enable); -c2h_id_filter c2h_id_filter_ccx; };#define RF_CHANGE_BY_INIT 0
Signature · 1 line
2.31.1