Skip to contentSkip to conversation

staging: rtl8723bs: handle key setup failures

PATCH In review Lucas Jeffrey 2 participants 2 messages Aug 3 – Sep 1 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: handle key setup failures

The return values from key setup helpers were ignored in rtw_cfg80211_ap_set_encryption().

Propagate failures from rtw_ap_set_wep_key(), rtw_ap_set_group_key(), and rtw_ap_set_pairwise_key() back to cfg80211 instead of continuing after an unsuccessful key setup.

This avoids silently reporting success when the key setup command could not be queued or helper functions fail to allocate memory.

---
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +15 -4
index 967cd1b34aed..8e5aa036d5eb 100644
@@ -563,7 +563,9 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
 
 		psecuritypriv->dot11DefKeylen[wep_key_idx] = wep_key_len;
 
-		rtw_ap_set_wep_key(padapter, param->u.crypt.key, wep_key_len, wep_key_idx, 1);
+		if (rtw_ap_set_wep_key(padapter, param->u.crypt.key, wep_key_len, wep_key_idx, 1) == _FAIL)
+			ret = -EIO;
+
 
 		goto exit;
 	}
@@ -604,7 +606,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
 
 			psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/*  */
 
-			rtw_ap_set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx);
+			if (rtw_ap_set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx) == _FAIL) {
+				ret = -EIO;
+				goto exit;
+			}
 
 			pbcmc_sta = rtw_get_bcmc_stainfo(padapter);
 			if (pbcmc_sta) {
@@ -640,7 +645,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
 					psta->dot118021XPrivacy = _NO_PRIVACY_;
 				}
 
-				rtw_ap_set_pairwise_key(padapter, psta);
+				if (rtw_ap_set_pairwise_key(padapter, psta) == _FAIL) {
+					ret = -EIO;
+					goto exit;
+				}
 
 				psta->ieee8021x_blocked = false;
 
@@ -678,7 +686,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
 
 				psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/*  */
 
-				rtw_ap_set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx);
+				if (rtw_ap_set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx) == _FAIL) {
+					ret = -EIO;
+					goto exit;
+				}
 
 				pbcmc_sta = rtw_get_bcmc_stainfo(padapter);
 				if (pbcmc_sta) {
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 20 lines · Lucas Jeffrey

The return values from key setup helpers were ignored in rtw_cfg80211_ap_set_encryption().

Propagate failures from rtw_ap_set_wep_key(), rtw_ap_set_group_key(), and rtw_ap_set_pairwise_key() back to cfg80211 instead of continuing after an unsuccessful key setup.

This avoids silently reporting success when the key setup command could not be queued or helper functions fail to allocate memory.

---
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +0 -0
index 967cd1b34aed..8e5aa036d5eb 100644

drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa · line 568

Quoted 7 lines
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +3 -1
@@ -563,7 +563,9 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
 
 		psecuritypriv->dot11DefKeylen[wep_key_idx] = wep_key_len;
 
-		rtw_ap_set_wep_key(padapter, param->u.crypt.key, wep_key_len, wep_key_idx, 1);
+		if (rtw_ap_set_wep_key(padapter, param->u.crypt.key, wep_key_len, wep_key_idx, 1) == _FAIL)
+			ret = -EIO;
+

Why the extra blank line?

thanks,

greg k-h