staging: rtl8723bs: core/rtw_mlme_ext.c: refactor security IE parsing in OnAssocReq
PATCH 1/5 staging: rtl8723bs: core/rtw_mlme_ext.c: refactor security IE parsing in OnAssocReq
Refactor security ies parsing in OnAssocReq function into separate helper function rtw_parse_assoc_security_ies.
Local variables from OnAssocReq wpa_ie, wpa_ie_len and psecuritypriv moved into helper function as they're only used within the function.
This change significantly shortens OnAssocReq, and makes the logic easier to reason about.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 231 +++++++++--------- 1 file changed, 119 insertions(+), 112 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +119 -112
@@ -929,20 +929,132 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram } +static unsigned short rtw_parse_assoc_security_ies (struct adapter *padapter, +struct rtw_ieee802_11_elems *elems, +struct sta_info *pstat) +{ +struct security_priv *psecuritypriv = &padapter->securitypriv; +struct mlme_priv *pmlmepriv = &padapter->mlmepriv; +unsigned char *wpa_ie; +int wpa_ie_len; + + pstat->dot8021xalg =0 ; + pstat->wpa_psk =0 ; + pstat->wpa_group_cipher =0 ; + pstat->wpa2_group_cipher =0 ; + pstat->wpa_pairwise_cipher =0 ; + pstat->wpa2_pairwise_cipher =0 ; +memset (pstat->wpa_ie,0 ,sizeof (pstat->wpa_ie)); +if ((psecuritypriv->wpa_psk &BIT (1 )) && elems->rsn_ie) { + +int group_cipher =0 , pairwise_cipher =0 ; + + wpa_ie = elems->rsn_ie; + wpa_ie_len = elems->rsn_ie_len; + +if (rtw_parse_wpa2_ie (wpa_ie-2 , wpa_ie_len+2 , &group_cipher, &pairwise_cipher,NULL ) == _SUCCESS) { + pstat->dot8021xalg =1 ;/* psk, todo:802.1x */ + pstat->wpa_psk |=BIT (1 ); + + pstat->wpa2_group_cipher = group_cipher&psecuritypriv->wpa2_group_cipher; + pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; + +if (!pstat->wpa2_group_cipher) +return WLAN_STATUS_INVALID_GROUP_CIPHER ; + +if (!pstat->wpa2_pairwise_cipher) +return WLAN_STATUS_INVALID_PAIRWISE_CIPHER ; + }else { +return WLAN_STATUS_INVALID_IE ; + } + + }else if ((psecuritypriv->wpa_psk &BIT (0 )) && elems->wpa_ie) { + +int group_cipher =0 , pairwise_cipher =0 ; + + wpa_ie = elems->wpa_ie; + wpa_ie_len = elems->wpa_ie_len; + +if (rtw_parse_wpa_ie (wpa_ie-2 , wpa_ie_len+2 , &group_cipher, &pairwise_cipher,NULL ) == _SUCCESS) { + pstat->dot8021xalg =1 ;/* psk, todo:802.1x */ + pstat->wpa_psk |=BIT (0 ); + + pstat->wpa_group_cipher = group_cipher&psecuritypriv->wpa_group_cipher; + pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; + +if (!pstat->wpa_group_cipher) +return WLAN_STATUS_INVALID_GROUP_CIPHER ; + +if (!pstat->wpa_pairwise_cipher) +return WLAN_STATUS_INVALID_PAIRWISE_CIPHER ; + + }else { +return WLAN_STATUS_INVALID_IE ; + } + + }else { + wpa_ie =NULL ; + wpa_ie_len =0 ; + } + + pstat->flags &= ~(WLAN_STA_WPS |WLAN_STA_MAYBE_WPS ); +if (!wpa_ie) { +if (elems->wps_ie) { + pstat->flags |=WLAN_STA_WPS ; + }else { + pstat->flags |=WLAN_STA_MAYBE_WPS ; + } + + +/* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ +/* that the selected registrar of AP is _FLASE */ +if ((psecuritypriv->wpa_psk >0 ) + && (pstat->flags & (WLAN_STA_WPS |WLAN_STA_MAYBE_WPS ))) { +if (pmlmepriv->wps_beacon_ie) { +u8 selected_registrar =0 ; + +rtw_get_wps_attr_content (pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len,WPS_ATTR_SELECTED_REGISTRAR , &selected_registrar,NULL ); + +if (!selected_registrar) +return WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA ; + } + } + + }else { +int copy_len; + +if (psecuritypriv->wpa_psk ==0 ) { +return WLAN_STATUS_INVALID_IE ; + } + +if (elems->wps_ie) { + pstat->flags |=WLAN_STA_WPS ; + copy_len =0 ; + }else { + copy_len = ((wpa_ie_len+2 ) >sizeof (pstat->wpa_ie)) ? (sizeof (pstat->wpa_ie)):(wpa_ie_len+2 ); + } + + +if (copy_len >0 ) +memcpy (pstat->wpa_ie, wpa_ie-2 , copy_len); + + } +return WLAN_STATUS_SUCCESS ; +} +unsigned int OnAssocReq (struct adapter *padapter,union recv_frame *precv_frame) {u16 capab_info;struct rtw_ieee802_11_elems elems;struct sta_info *pstat; -unsigned char *p, *pos, *wpa_ie; +unsigned char *p, *pos;unsigned char WMM_IE [] = {0x00 ,0x50 ,0xf2 ,0x02 ,0x00 ,0x01 }; -int i, ie_len, wpa_ie_len, left; +int i, ie_len, left;unsigned char supportRate[16 ];int supportRateNum; -unsigned short status =WLAN_STATUS_SUCCESS ; +unsigned short status =WLAN_STATUS_SUCCESS , parse_status;unsigned short frame_type, ie_offset =0 ;struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -struct security_priv *psecuritypriv = &padapter->securitypriv;struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);struct wlan_bssid_ex *cur = &(pmlmeinfo->network);
@@ -1056,118 +1168,13 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)update_basic_rate_table_soft_ap (pstat->bssrateset, pstat->bssratelen);/* check RSN/WPA/WPS */ - pstat->dot8021xalg =0 ; - pstat->wpa_psk =0 ; - pstat->wpa_group_cipher =0 ; - pstat->wpa2_group_cipher =0 ; - pstat->wpa_pairwise_cipher =0 ; - pstat->wpa2_pairwise_cipher =0 ; -memset (pstat->wpa_ie,0 ,sizeof (pstat->wpa_ie)); -if ((psecuritypriv->wpa_psk &BIT (1 )) && elems.rsn_ie) { - -int group_cipher =0 , pairwise_cipher =0 ; - - wpa_ie = elems.rsn_ie; - wpa_ie_len = elems.rsn_ie_len; - -if (rtw_parse_wpa2_ie (wpa_ie-2 , wpa_ie_len+2 , &group_cipher, &pairwise_cipher,NULL ) == _SUCCESS) { - pstat->dot8021xalg =1 ;/* psk, todo:802.1x */ - pstat->wpa_psk |=BIT (1 ); - - pstat->wpa2_group_cipher = group_cipher&psecuritypriv->wpa2_group_cipher; - pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; - -if (!pstat->wpa2_group_cipher) - status =WLAN_STATUS_INVALID_GROUP_CIPHER ; - -if (!pstat->wpa2_pairwise_cipher) - status =WLAN_STATUS_INVALID_PAIRWISE_CIPHER ; - }else { - status =WLAN_STATUS_INVALID_IE ; - } - - }else if ((psecuritypriv->wpa_psk &BIT (0 )) && elems.wpa_ie) { - -int group_cipher =0 , pairwise_cipher =0 ; - - wpa_ie = elems.wpa_ie; - wpa_ie_len = elems.wpa_ie_len; - -if (rtw_parse_wpa_ie (wpa_ie-2 , wpa_ie_len+2 , &group_cipher, &pairwise_cipher,NULL ) == _SUCCESS) { - pstat->dot8021xalg =1 ;/* psk, todo:802.1x */ - pstat->wpa_psk |=BIT (0 ); - - pstat->wpa_group_cipher = group_cipher&psecuritypriv->wpa_group_cipher; - pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; - -if (!pstat->wpa_group_cipher) - status =WLAN_STATUS_INVALID_GROUP_CIPHER ; - -if (!pstat->wpa_pairwise_cipher) - status =WLAN_STATUS_INVALID_PAIRWISE_CIPHER ; - - }else { - status =WLAN_STATUS_INVALID_IE ; - } - - }else { - wpa_ie =NULL ; - wpa_ie_len =0 ; - } + parse_status =rtw_parse_assoc_security_ies (padapter, &elems, pstat); +if (parse_status !=WLAN_STATUS_SUCCESS ) + status = parse_status;if (status !=WLAN_STATUS_SUCCESS ) goto OnAssocReqFail; - pstat->flags &= ~(WLAN_STA_WPS |WLAN_STA_MAYBE_WPS ); -if (!wpa_ie) { -if (elems.wps_ie) { - pstat->flags |=WLAN_STA_WPS ; - }else { - pstat->flags |=WLAN_STA_MAYBE_WPS ; - } - - -/* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ -/* that the selected registrar of AP is _FLASE */ -if ((psecuritypriv->wpa_psk >0 ) - && (pstat->flags & (WLAN_STA_WPS |WLAN_STA_MAYBE_WPS ))) { -if (pmlmepriv->wps_beacon_ie) { -u8 selected_registrar =0 ; - -rtw_get_wps_attr_content (pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len,WPS_ATTR_SELECTED_REGISTRAR , &selected_registrar,NULL ); - -if (!selected_registrar) { - status =WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA ; - - goto OnAssocReqFail; - } - } - } - - }else { -int copy_len; - -if (psecuritypriv->wpa_psk ==0 ) { - status =WLAN_STATUS_INVALID_IE ; - - goto OnAssocReqFail; - - } - -if (elems.wps_ie) { - pstat->flags |=WLAN_STA_WPS ; - copy_len =0 ; - }else { - copy_len = ((wpa_ie_len+2 ) >sizeof (pstat->wpa_ie)) ? (sizeof (pstat->wpa_ie)):(wpa_ie_len+2 ); - } - - -if (copy_len >0 ) -memcpy (pstat->wpa_ie, wpa_ie-2 , copy_len); - - } - -/* check if there is WMM IE & support WWM-PS */ pstat->flags &= ~WLAN_STA_WME ; pstat->qos_option =0 ;
Signature · 1 line
2.52.0
PATCH 2/5 staging: rtl8723bs: core/rtw_mlme_ext.c: remove unnecessary else statement
Replace else-statement setting wpa_ie to NULL and wpa_ie_len to 0 by initialising these variables beforehand.
Else-statement which sets wpa_ie and wpa_ie_len is unnecessary if variables are initialised to these values from the start.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +2 -6
@@ -935,8 +935,8 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, {struct security_priv *psecuritypriv = &padapter->securitypriv;struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -unsigned char *wpa_ie; -int wpa_ie_len; +unsigned char *wpa_ie =NULL ; +int wpa_ie_len =0 ; pstat->dot8021xalg =0 ; pstat->wpa_psk =0 ;
@@ -991,10 +991,6 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, }else {return WLAN_STATUS_INVALID_IE ; } - - }else { - wpa_ie =NULL ; - wpa_ie_len =0 ; } pstat->flags &= ~(WLAN_STA_WPS |WLAN_STA_MAYBE_WPS );
Signature · 1 line
2.52.0
PATCH 3/5 staging: rtl8723bs: core/rtw_mlme_ext.c: remove braces for one-line if-statements.
In reply to William Hansen-BairdRemove unecessary braces for if-statements that have only 1 line in rtw_parse_security_ies function.
This change is purely stylistic, and makes the single-line if-statements take up less space.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +4 -6
@@ -995,12 +995,10 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, pstat->flags &= ~(WLAN_STA_WPS |WLAN_STA_MAYBE_WPS );if (!wpa_ie) { -if (elems->wps_ie) { +if (elems->wps_ie) pstat->flags |=WLAN_STA_WPS ; - }else { +else pstat->flags |=WLAN_STA_MAYBE_WPS ; - } -/* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ /* that the selected registrar of AP is _FLASE */
@@ -1019,9 +1017,8 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, }else {int copy_len; -if (psecuritypriv->wpa_psk ==0 ) { +if (psecuritypriv->wpa_psk ==0 )return WLAN_STATUS_INVALID_IE ; - }if (elems->wps_ie) { pstat->flags |=WLAN_STA_WPS ;
@@ -1035,6 +1032,7 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter,memcpy (pstat->wpa_ie, wpa_ie-2 , copy_len); } +return WLAN_STATUS_SUCCESS ; }
Signature · 1 line
2.52.0
PATCH 4/5 staging: rtl8723bs: replace ternary comparison with min_t()
In reply to William Hansen-BairdReplace ternary comparison for setting copy_len with the min_t() function from linux/minmax.h.
Change is purely cosmetic, however makes the line easier to read without having to reason about logic.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +2 -3
@@ -4,6 +4,7 @@* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ +#include <linux/minmax.h> #include <drv_types.h> #include <rtw_wifi_regd.h> #include <hal_btcoex.h>
@@ -1024,13 +1025,11 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, pstat->flags |=WLAN_STA_WPS ; copy_len =0 ; }else { - copy_len = ((wpa_ie_len+2 ) >sizeof (pstat->wpa_ie)) ? (sizeof (pstat->wpa_ie)):(wpa_ie_len+2 ); + copy_len =min_t (int,sizeof (pstat->wpa_ie), wpa_ie_len+2 ); } -if (copy_len >0 )memcpy (pstat->wpa_ie, wpa_ie-2 , copy_len); - }return WLAN_STATUS_SUCCESS ;
Signature · 1 line
2.52.0
Greg KH
maintainerRe: [PATCH 4/5] staging: rtl8723bs: replace ternary comparison with min_t()
Quoted 23 lines · William Hansen-Baird
Replace ternary comparison for setting
copy_lenwith themin_t()function fromlinux/minmax.h.
Change is purely cosmetic, however makes the line easier to read without having to reason about logic.Signed-off-by William Hansen-Baird <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1
-0@@ -4,6 +4,7 @@* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ +#include <linux/minmax.h> #include <drv_types.h> #include <rtw_wifi_regd.h> #include <hal_btcoex.h>
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, · line 1028
Quoted 5 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1
-1@@ -1024,13 +1025,11 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, pstat->flags |=WLAN_STA_WPS ; copy_len =0 ; }else { - copy_len = ((wpa_ie_len+2 ) >sizeof (pstat->wpa_ie)) ? (sizeof (pstat->wpa_ie)):(wpa_ie_len+2 ); + copy_len =min_t (int,sizeof (pstat->wpa_ie), wpa_ie_len+2 );
Why is the type needed here?
And your new line has a coding style problem, always run your patches through checkpatch.pl please.
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, · line 1033
Quoted 6 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-2} -if (copy_len >0 )memcpy (pstat->wpa_ie, wpa_ie-2 , copy_len); -
These lines are not mentioned in the changelog :(
Remember, only do 1 thing per patch.
thanks,
greg k-h
PATCH 5/5 staging: rtl8723bs: core/rtw_mlme_ext.c: initialize copy_len, clearing later control-flow.
In reply to William Hansen-BairdInitialize copy_len to 0 in rtw_parse_assoc_security_ies function. This allows later if-statement to not have to explicitly set copy_len to 0. Thus we can make the if statement single-lined, and remove the braces from the if-else branch.
The change is purely cosmetic and changes no logic.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +4 -5
@@ -946,6 +946,7 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, pstat->wpa_pairwise_cipher =0 ; pstat->wpa2_pairwise_cipher =0 ;memset (pstat->wpa_ie,0 ,sizeof (pstat->wpa_ie)); +if ((psecuritypriv->wpa_psk &BIT (1 )) && elems->rsn_ie) {int group_cipher =0 , pairwise_cipher =0 ;
@@ -1016,17 +1017,15 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, } }else { -int copy_len; +int copy_len =0 ;if (psecuritypriv->wpa_psk ==0 )return WLAN_STATUS_INVALID_IE ; -if (elems->wps_ie) { +if (elems->wps_ie) pstat->flags |=WLAN_STA_WPS ; - copy_len =0 ; - }else { +else copy_len =min_t (int,sizeof (pstat->wpa_ie), wpa_ie_len+2 ); - }if (copy_len >0 )memcpy (pstat->wpa_ie, wpa_ie-2 , copy_len);
Signature · 1 line
2.52.0
Greg KH
maintainerRe: [PATCH 5/5] staging: rtl8723bs: core/rtw_mlme_ext.c: initialize copy_len, clearing later control-flow.
Quoted 16 lines · William Hansen-Baird
Initialize
copy_lento 0 inrtw_parse_assoc_security_iesfunction. This allows later if-statement to not have to explicitly setcopy_lento 0. Thus we can make the if statement single-lined, and remove the braces from the if-else branch.
The change is purely cosmetic and changes no logic.Signed-off-by William Hansen-Baird <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-0
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, · line 952
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1
-0@@ -946,6 +946,7 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, pstat->wpa_pairwise_cipher =0 ; pstat->wpa2_pairwise_cipher =0 ;memset (pstat->wpa_ie,0 ,sizeof (pstat->wpa_ie)); +if ((psecuritypriv->wpa_psk &BIT (1 )) && elems->rsn_ie) {int group_cipher =0 , pairwise_cipher =0 ;
Why this line added?
Quoted 11 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1
-2@@ -1016,17 +1017,15 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, } }else { -int copy_len; +int copy_len =0 ;if (psecuritypriv->wpa_psk ==0 )return WLAN_STATUS_INVALID_IE ; -if (elems->wps_ie) {
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, · line 1031
Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +2
-3+if (elems->wps_ie) pstat->flags |=WLAN_STA_WPS ; - copy_len =0 ; - }else { +else copy_len =min_t (int,sizeof (pstat->wpa_ie), wpa_ie_len+2 ); - }if (copy_len >0 )memcpy (pstat->wpa_ie, wpa_ie-2 , copy_len);
I feel like this is just polishing the code for no reason at all. Why make this change at all? What asked for it?
thanks,
greg k-h
Re: [PATCH 5/5] staging: rtl8723bs: core/rtw_mlme_ext.c: initialize copy_len, clearing later control-flow.
Quoted 46 lines · Greg KH
Quoted 16 lines · William Hansen-Baird
Initialize
copy_lento 0 inrtw_parse_assoc_security_iesfunction. This allows later if-statement to not have to explicitly setcopy_lento 0. Thus we can make the if statement single-lined, and remove the braces from the if-else branch.
The change is purely cosmetic and changes no logic.Signed-off-by William Hansen-Baird <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-0drivers/staging/rtl8723bs/core/rtw_mlme_ext.c static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, · line 952
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1
-0@@ -946,6 +946,7 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, pstat->wpa_pairwise_cipher =0 ; pstat->wpa2_pairwise_cipher =0 ;memset (pstat->wpa_ie,0 ,sizeof (pstat->wpa_ie)); +if ((psecuritypriv->wpa_psk &BIT (1 )) && elems->rsn_ie) {int group_cipher =0 , pairwise_cipher =0 ;Why this line added?
Quoted 19 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +3
-5@@ -1016,17 +1017,15 @@ static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, } }else { -int copy_len; +int copy_len =0 ;if (psecuritypriv->wpa_psk ==0 )return WLAN_STATUS_INVALID_IE ; -if (elems->wps_ie) { +if (elems->wps_ie) pstat->flags |=WLAN_STA_WPS ; - copy_len =0 ; - }else { +else copy_len =min_t (int,sizeof (pstat->wpa_ie), wpa_ie_len+2 ); - }
Quoted 6 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c static unsigned short rtw_parse_assoc_security_ies(struct adapter *padapter, · line 1031
Quoted 2 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-0if (copy_len >0 )memcpy (pstat->wpa_ie, wpa_ie-2 , copy_len);I feel like this is just polishing the code for no reason at all. Why make this change at all? What asked for it?
The change was really only polishing. There wasn't an issue to solve and it was mainly a stylistic choice on my part.
If you prefer, I can drop this patch and keep the original style.
Thanks,
William
Greg KH
maintainerdrivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) · line 1176
Quoted 6 lines · William Hansen-Baird
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +3
-0+ parse_status =rtw_parse_assoc_security_ies (padapter, &elems, pstat); +if (parse_status !=WLAN_STATUS_SUCCESS ) + status = parse_status;if (status !=WLAN_STATUS_SUCCESS ) goto OnAssocReqFail;
This logic makes no sense. Did you do this by hand or have a tool do it for you?
thanks,
greg k-h
Quoted 11 lines · Greg KH
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) · line 1176
Quoted 6 lines · William Hansen-Baird
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +3
-0+ parse_status =rtw_parse_assoc_security_ies (padapter, &elems, pstat); +if (parse_status !=WLAN_STATUS_SUCCESS ) + status = parse_status;if (status !=WLAN_STATUS_SUCCESS ) goto OnAssocReqFail;This logic makes no sense. Did you do this by hand or have a tool do it for you?
I did it by hand. The original code checked the status after parsing security IEs, only overwriting 'status' on parsing errors.
To preserve the original logic, I only overwrite 'status' if the parsing of the security IEs was not successful.
Thanks,
William