From aa66fbb956d4b464d39176045c2b431da56f358f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:31 +0200 Subject: [PATCH] staging: rtl8723au: validate_recv_data_frame() use fctl knowledge to obtain bssid Use the knowledge we already have from parsing the TODS/FROMDS bits in hdr->frame_control to obtain the bssid. Note that get_hdr_bssid() would never return NULL as handling 4 combinations of a 2 bit word leaves little space for falling through to the 'default' value. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index fd0958b675d5..3376a65d956a 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1308,9 +1308,8 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter, struct recv_frame *precv_frame) { u8 bretry; - u8 *psa, *pda, *pbssid; + u8 *psa, *pda; struct sta_info *psta = NULL; - u8 *ptr = precv_frame->pkt->data; struct rx_pkt_attrib *pattrib = & precv_frame->attrib; struct security_priv *psecuritypriv = &adapter->securitypriv; int ret = _SUCCESS; @@ -1322,39 +1321,39 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter, bretry = ieee80211_has_retry(hdr->frame_control); pda = ieee80211_get_DA(hdr); psa = ieee80211_get_SA(hdr); - pbssid = get_hdr_bssid(ptr); - - if (pbssid == NULL) { - ret = _FAIL; - goto exit; - } ether_addr_copy(pattrib->dst, pda); ether_addr_copy(pattrib->src, psa); - ether_addr_copy(pattrib->bssid, pbssid); - switch (hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) { case cpu_to_le16(0): + ether_addr_copy(pattrib->bssid, hdr->addr3); ether_addr_copy(pattrib->ra, pda); ether_addr_copy(pattrib->ta, psa); ret = sta2sta_data_frame(adapter, precv_frame, &psta); break; case cpu_to_le16(IEEE80211_FCTL_FROMDS): + ether_addr_copy(pattrib->bssid, hdr->addr2); ether_addr_copy(pattrib->ra, pda); - ether_addr_copy(pattrib->ta, pbssid); + ether_addr_copy(pattrib->ta, hdr->addr2); ret = ap2sta_data_frame(adapter, precv_frame, &psta); break; case cpu_to_le16(IEEE80211_FCTL_TODS): - ether_addr_copy(pattrib->ra, pbssid); + ether_addr_copy(pattrib->bssid, hdr->addr1); + ether_addr_copy(pattrib->ra, hdr->addr1); ether_addr_copy(pattrib->ta, psa); ret = sta2ap_data_frame(adapter, precv_frame, &psta); break; case cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): + /* + * There is no BSSID in this case, but the driver has been + * using addr1 so far, so keep it for now. + */ + ether_addr_copy(pattrib->bssid, hdr->addr1); ether_addr_copy(pattrib->ra, hdr->addr1); ether_addr_copy(pattrib->ta, hdr->addr2); ret = _FAIL; -- 2.20.1