staging: rtl8723bs: remove unreachable code in
cover staging: rtl8723bs: remove unreachable code in
This series removes an unreachable switch-case branch in the update_beacon() function. This branch doesn't check the value of the 'oui' pointer, which could lead to a NULL dereference.
Found with cppcheck:
core/rtw_ap.c:1404:27: error: Null pointer dereference: oui [ctunullpointer]
if (!memcmp(RTW_WPA_OUI, oui, 4))
^
core/rtw_ap.c:235:19: note: Calling function update_beacon, 3rd argument is null
update_beacon(padapter, WLAN_EID_TIM, NULL, true);
^
core/rtw_ap.c:1472:3: note: Calling function update_bcn_vendor_spec_ie, 2nd argument is null
update_bcn_vendor_spec_ie(padapter, oui);
^
core/rtw_ap.c:1404:27: note: Dereferencing argument oui that is null
if (!memcmp(RTW_WPA_OUI, oui, 4))
^Nikolay Kulikov (2):
staging: rtl8723bs: remove unused case from update_beacon()
staging: rtl8723bs: remove unused 'oui' parameter from update_beacon()
drivers/staging/rtl8723bs/core/rtw_ap.c | 116 +++------------------ drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/core/rtw_recv.c | 4 +- drivers/staging/rtl8723bs/core/rtw_xmit.c | 8 +- drivers/staging/rtl8723bs/include/rtw_ap.h | 2 +- 5 files changed, 24 insertions(+), 108 deletions(-)
base-commit: 7cb1c5b32a2bfde961fff8d5204526b609bcb30a
Signature · 1 line
2.54.0
PATCH 1/2 staging: rtl8723bs: remove unused case from update_beacon()
The update_beacon() function is never called with 'ie_id' equal to 'WLAN_EID_VENDOR_SPECIFIC', meaning this case branch will never be called, so remove it and several related functions.
Removing this case branch also fixes a possible null pointer dereference in update_bcn_vendor_spec() if 'oui' is NULL, since its value is not checked in any way.
--- drivers/staging/rtl8723bs/core/rtw_ap.c | 84 ------------------------- 1 file changed, 84 deletions(-)
drivers/staging/rtl8723bs/core/rtw_ap.c +0 -84
@@ -1336,84 +1336,6 @@ static void update_bcn_rsn_ie(struct adapter *padapter) { } -static void update_bcn_wpa_ie (struct adapter *padapter) -{ -} - -static void update_bcn_wmm_ie (struct adapter *padapter) -{ -} - -static void update_bcn_wps_ie (struct adapter *padapter) -{ -u8 *pwps_ie =NULL ; -u8 *pwps_ie_src; -u8 *premainder_ie; -u8 *pbackup_remainder_ie =NULL ; - -unsigned int wps_ielen =0 , wps_offset, remainder_ielen; -struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; -struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; -unsigned char *ie = pnetwork->ies; -u32 ielen = pnetwork->ie_length; - - pwps_ie =rtw_get_wps_ie (ie + _FIXED_IE_LENGTH_, - ielen - _FIXED_IE_LENGTH_, -NULL , - &wps_ielen); - -if (!pwps_ie || wps_ielen ==0 ) -return ; - - pwps_ie_src = pmlmepriv->wps_beacon_ie; -if (!pwps_ie_src) -return ; - - wps_offset = (unsigned int )(pwps_ie - ie); - - premainder_ie = pwps_ie + wps_ielen; - - remainder_ielen = ielen - wps_offset - wps_ielen; - -if (remainder_ielen) - pbackup_remainder_ie =kmemdup (premainder_ie, remainder_ielen,GFP_ATOMIC ); - - wps_ielen = (unsigned int )pwps_ie_src[1 ];/* to get ie data len */ -if ((wps_offset + wps_ielen +2 + remainder_ielen) <=MAX_IE_SZ ) { -memcpy (pwps_ie, pwps_ie_src, wps_ielen +2 ); - pwps_ie += (wps_ielen +2 ); - -if (pbackup_remainder_ie) -memcpy (pwps_ie, pbackup_remainder_ie, remainder_ielen); - -/* update ie_length */ - pnetwork->ie_length = wps_offset + (wps_ielen +2 ) + remainder_ielen; - } - -kfree (pbackup_remainder_ie); -} - -static void update_bcn_p2p_ie (struct adapter *padapter) -{ -} - -static void update_bcn_vendor_spec_ie (struct adapter *padapter,u8 *oui) -{ -if (!memcmp (RTW_WPA_OUI , oui,4 )) -update_bcn_wpa_ie (padapter); - -else if (!memcmp (WMM_OUI , oui,4 )) -update_bcn_wmm_ie (padapter); - -else if (!memcmp (WPS_OUI , oui,4 )) -update_bcn_wps_ie (padapter); - -else if (!memcmp (P2P_OUI , oui,4 )) -update_bcn_p2p_ie (padapter); -} -void update_beacon (struct adapter *padapter,u8 ie_id,u8 *oui,u8 tx) {struct mlme_priv *pmlmepriv;
@@ -1467,12 +1389,6 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx)break ; -case WLAN_EID_VENDOR_SPECIFIC : - -update_bcn_vendor_spec_ie (padapter, oui); - -break ; -default :break ; }
Signature · 1 line
2.54.0
PATCH 2/2 staging: rtl8723bs: remove unused 'oui' parameter from update_beacon()
In reply to Nikolay KulikovAfter deleting one of the switch-case branches, this parameter became unused, so remove it.
--- drivers/staging/rtl8723bs/core/rtw_ap.c | 32 +++++++++++----------- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/core/rtw_recv.c | 4 +-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 8 +++--- drivers/staging/rtl8723bs/include/rtw_ap.h | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-)
drivers/staging/rtl8723bs/core/rtw_ap.c +16 -16
@@ -232,7 +232,7 @@ void expire_timeout_chk(struct adapter *padapter)/* to update bcn with tim_bitmap for this station */ pstapriv->tim_bitmap |=BIT (psta->aid); -update_beacon (padapter,WLAN_EID_TIM ,NULL , true); +update_beacon (padapter,WLAN_EID_TIM , true);if (!pmlmeext->active_keep_alive_check)continue ;
@@ -739,7 +739,7 @@ void start_bss_network(struct adapter *padapter) rtw_get_capability((struct wlan_bssid_ex *)pnetwork));if (pmlmeext->bstart_bss) { -update_beacon (padapter,WLAN_EID_TIM ,NULL , true); +update_beacon (padapter,WLAN_EID_TIM , true);/* issue beacon frame */ send_beacon (padapter);
@@ -1336,7 +1336,7 @@ static void update_bcn_rsn_ie(struct adapter *padapter) { } -void update_beacon (struct adapter *padapter,u8 ie_id,u8 *oui,u8 tx) +void update_beacon (struct adapter *padapter,u8 ie_id,u8 tx) {struct mlme_priv *pmlmepriv;struct mlme_ext_priv *pmlmeext;
@@ -1513,7 +1513,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)if ((pmlmeext->cur_wireless_mode >WIRELESS_11B ) && (pmlmepriv->num_sta_no_short_preamble ==1 )) { beacon_updated = true; -update_beacon (padapter,0xFF ,NULL , true); +update_beacon (padapter,0xFF , true); } } }else {
@@ -1525,7 +1525,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)if ((pmlmeext->cur_wireless_mode >WIRELESS_11B ) && (pmlmepriv->num_sta_no_short_preamble ==0 )) { beacon_updated = true; -update_beacon (padapter,0xFF ,NULL , true); +update_beacon (padapter,0xFF , true); } } }
@@ -1538,7 +1538,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)if (pmlmepriv->num_sta_non_erp ==1 ) { beacon_updated = true; -update_beacon (padapter,WLAN_EID_ERP_INFO ,NULL , true); +update_beacon (padapter,WLAN_EID_ERP_INFO , true); } } }else {
@@ -1549,7 +1549,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)if (pmlmepriv->num_sta_non_erp ==0 ) { beacon_updated = true; -update_beacon (padapter,WLAN_EID_ERP_INFO ,NULL , true); +update_beacon (padapter,WLAN_EID_ERP_INFO , true); } } }
@@ -1563,7 +1563,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)if ((pmlmeext->cur_wireless_mode >WIRELESS_11B ) && (pmlmepriv->num_sta_no_short_slot_time ==1 )) { beacon_updated = true; -update_beacon (padapter,0xFF ,NULL , true); +update_beacon (padapter,0xFF , true); } } }else {
@@ -1575,7 +1575,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)if ((pmlmeext->cur_wireless_mode >WIRELESS_11B ) && (pmlmepriv->num_sta_no_short_slot_time ==0 )) { beacon_updated = true; -update_beacon (padapter,0xFF ,NULL , true); +update_beacon (padapter,0xFF , true); } } }
@@ -1610,8 +1610,8 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) }if (rtw_ht_operation_update (padapter) >0 ) { -update_beacon (padapter,WLAN_EID_HT_CAPABILITY ,NULL , false); -update_beacon (padapter,WLAN_EID_HT_OPERATION ,NULL , true); +update_beacon (padapter,WLAN_EID_HT_CAPABILITY , false); +update_beacon (padapter,WLAN_EID_HT_OPERATION , true); }/* update associated stations cap. */
@@ -1633,7 +1633,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta)if (pmlmeext->cur_wireless_mode >WIRELESS_11B && pmlmepriv->num_sta_no_short_preamble ==0 ){ beacon_updated = true; -update_beacon (padapter,0xFF ,NULL , true); +update_beacon (padapter,0xFF , true); } }
@@ -1642,7 +1642,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_non_erp--;if (pmlmepriv->num_sta_non_erp ==0 ) { beacon_updated = true; -update_beacon (padapter,WLAN_EID_ERP_INFO ,NULL , true); +update_beacon (padapter,WLAN_EID_ERP_INFO , true); } }
@@ -1652,7 +1652,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta)if (pmlmeext->cur_wireless_mode >WIRELESS_11B && pmlmepriv->num_sta_no_short_slot_time ==0 ){ beacon_updated = true; -update_beacon (padapter,0xFF ,NULL , true); +update_beacon (padapter,0xFF , true); } }
@@ -1672,8 +1672,8 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) }if (rtw_ht_operation_update (padapter) >0 ) { -update_beacon (padapter,WLAN_EID_HT_CAPABILITY ,NULL , false); -update_beacon (padapter,WLAN_EID_HT_OPERATION ,NULL , true); +update_beacon (padapter,WLAN_EID_HT_CAPABILITY , false); +update_beacon (padapter,WLAN_EID_HT_OPERATION , true); }return beacon_updated;
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -1
@@ -1526,7 +1526,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) pstapriv->sta_dz_bitmap &= ~BIT (0 );if (update_tim) -update_beacon (padapter,WLAN_EID_TIM ,NULL , true); +update_beacon (padapter,WLAN_EID_TIM , true); }else {/* re check again */ rtw_chk_hi_queue_cmd (padapter); }
drivers/staging/rtl8723bs/core/rtw_recv.c +2 -2
@@ -1009,7 +1009,7 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_/* update BCN for TIM IE */ /* update_BCNTIM(padapter); */ -update_beacon (padapter,WLAN_EID_TIM ,NULL , true); +update_beacon (padapter,WLAN_EID_TIM , true); }/* spin_unlock_bh(&psta->sleep_q.lock); */
@@ -1031,7 +1031,7 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_/* update BCN for TIM IE */ /* update_BCNTIM(padapter); */ -update_beacon (padapter,WLAN_EID_TIM ,NULL , true); +update_beacon (padapter,WLAN_EID_TIM , true); } } }
drivers/staging/rtl8723bs/core/rtw_xmit.c +4 -4
@@ -2083,7 +2083,7 @@ signed int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct x pstapriv->sta_dz_bitmap |=BIT (0 );if (update_tim) -update_beacon (padapter,WLAN_EID_TIM ,NULL , true); +update_beacon (padapter,WLAN_EID_TIM , true);else chk_bmc_sleepq_cmd (padapter);
@@ -2138,7 +2138,7 @@ signed int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xif (update_tim)/* update BCN for TIM IE */ -update_beacon (padapter,WLAN_EID_TIM ,NULL , true); +update_beacon (padapter,WLAN_EID_TIM , true); } ret = true;
@@ -2333,7 +2333,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)spin_unlock_bh (&pxmitpriv->lock);if (update_mask) -update_beacon (padapter,WLAN_EID_TIM ,NULL , true); +update_beacon (padapter,WLAN_EID_TIM , true); }void xmit_delivery_enabled_frames (struct adapter *padapter,struct sta_info *psta)
@@ -2393,7 +2393,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pstif ((psta->sleepq_ac_len ==0 ) && (!psta->has_legacy_ac) && (wmmps_ac)) { pstapriv->tim_bitmap &= ~BIT (psta->aid); -update_beacon (padapter,WLAN_EID_TIM ,NULL , true); +update_beacon (padapter,WLAN_EID_TIM , true); } }
drivers/staging/rtl8723bs/include/rtw_ap.h +1 -1
@@ -10,7 +10,7 @@void init_mlme_ap_info (struct adapter *padapter);void free_mlme_ap_info (struct adapter *padapter);/* void update_BCNTIM(struct adapter *padapter); */ -void update_beacon (struct adapter *padapter,u8 ie_id,u8 *oui,u8 tx); +void update_beacon (struct adapter *padapter,u8 ie_id,u8 tx);void add_ratid (struct adapter *padapter,struct sta_info *psta,u8 rssi_level);void expire_timeout_chk (struct adapter *padapter);void update_sta_info_apmode (struct adapter *padapter,struct sta_info *psta);
Signature · 1 line
2.54.0