From: Jes Sorensen Date: Tue, 15 Apr 2014 17:43:58 +0000 (+0200) Subject: staging: rtl8723au: Make rtw_check_bcn_info23() take a ieee80211_mgmt pointer X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c146551f1a96eba625e80889fb947e7bd769bb78;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git staging: rtl8723au: Make rtw_check_bcn_info23() take a ieee80211_mgmt pointer Clean up the code by passing a struct ieee80211_mgmt pointer instead of a raw frame pointer. In addition check we receive a beacon frame, anything else here is an error. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index f810d8f8e384..a79861e4250c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -795,7 +795,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { - ret = rtw_check_bcn_info23a(padapter, pframe, + ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len); if (!ret) { DBG_8723A_LEVEL(_drv_always_, diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 17e32071b514..ac9d39a7c4f4 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -856,7 +856,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) } } -int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len) +int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, + struct ieee80211_mgmt *mgmt, u32 packet_len) { unsigned int len; unsigned char *p; @@ -874,12 +875,16 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le u32 bcn_channel; unsigned short ht_cap_info; unsigned char ht_info_infos_0; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe; - u8 *pbssid = hdr->addr3; if (is_client_associated_to_ap23a(Adapter) == false) return true; + if (unlikely(!ieee80211_is_beacon(mgmt->frame_control))) { + printk(KERN_WARNING "%s: received a non beacon frame!\n", + __func__); + return false; + } + len = packet_len - sizeof(struct ieee80211_hdr_3addr); if (len > MAX_IE_SZ) { @@ -887,23 +892,24 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le return _FAIL; } - if (memcmp(cur_network->network.MacAddress, pbssid, 6)) { - DBG_8723A("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n" MAC_FMT MAC_FMT, - MAC_ARG(pbssid), MAC_ARG(cur_network->network.MacAddress)); + if (memcmp(cur_network->network.MacAddress, mgmt->bssid, 6)) { + DBG_8723A("Oops: rtw_check_network_encrypt linked but recv " + "other bssid bcn\n" MAC_FMT MAC_FMT, + MAC_ARG(mgmt->bssid), + MAC_ARG(cur_network->network.MacAddress)); return true; } bssid = (struct wlan_bssid_ex *)kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); - if (ieee80211_is_beacon(hdr->frame_control)) - bssid->reserved = 1; + bssid->reserved = 1; bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; /* below is to copy the information element */ bssid->IELength = len; - memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength); + memcpy(bssid->IEs, &mgmt->u, bssid->IELength); /* check bw and channel offset */ /* parsing HT_CAP_IE */ diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 7f1cef124ee8..275f891b6c64 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -533,7 +533,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta); void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint len, struct sta_info *psta); -int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len); +int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, + struct ieee80211_mgmt *mgmt, u32 packet_len); void update_IOT_info23a(struct rtw_adapter *padapter); void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap); void update_wireless_mode23a(struct rtw_adapter * padapter);