Skip to contentSkip to conversation

staging: wlan-ng: fix exit return when sme->key_idx >= NUM_WEPKEYS

PATCH New Colin King 1 participant 1 message Oct 14, 2019

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 staging: wlan-ng: fix exit return when sme->key_idx >= NUM_WEPKEYS

From: Colin Ian King <[email protected]>

Currently the exit return path when sme->key_idx >= NUM_WEPKEYS is via label 'exit' and this checks if result is non-zero, however result has not been initialized and contains garbage. Fix this by replacing the goto with a return with the error code.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes 0ca6d8e74489 ("Staging: wlan-ng: replace switch-case statements with macro")
---
 drivers/staging/wlan-ng/cfg80211.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/wlan-ng/cfg80211.c +2 -4
index eee1998c4b18..fac38c842ac5 100644
@@ -469,10 +469,8 @@ static int prism2_connect(struct wiphy *wiphy, struct net_device *dev,
 	/* Set the encryption - we only support wep */
 	if (is_wep) {
 		if (sme->key) {
-			if (sme->key_idx >= NUM_WEPKEYS) {
-				err = -EINVAL;
-				goto exit;
-			}
+			if (sme->key_idx >= NUM_WEPKEYS)
+				return -EINVAL;
 
 			result = prism2_domibset_uint32(wlandev,
 				DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID,
Signature · 1 line
2.20.1