Skip to contentSkip to conversation

wireless: remove unreachable code

PATCH Applied Alan Cox 3 participants 3 messages Sep 17, 2012 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 wireless: remove unreachable code

From: Alan Cox <[email protected]>

The only case where intersected_rd can become non NULL is within an if. All paths from that if return, so the end chunk has therefore squawked its last and is no more.

---

 net/wireless/reg.c |   19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
net/wireless/reg.c +1 -18
index 1ad04e5..4a405c2 100644
@@ -2305,24 +2305,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
 		return 0;
 	}
 
-	if (!intersected_rd)
-		return -EINVAL;
-
-	rdev = wiphy_to_dev(request_wiphy);
-
-	rdev->country_ie_alpha2[0] = rd->alpha2[0];
-	rdev->country_ie_alpha2[1] = rd->alpha2[1];
-	rdev->env = last_request->country_ie_env;
-
-	BUG_ON(intersected_rd == rd);
-
-	kfree(rd);
-	rd = NULL;
-
-	reset_regdomains(false);
-	cfg80211_regdomain = intersected_rd;
-
-	return 0;
+	return -EINVAL;
 }
 
 
#1 lore raw
Quoted 5 lines · Alan Cox

From: Alan Cox <[email protected]>

The only case where intersected_rd can become non NULL is within an if. All paths from that if return, so the end chunk has therefore squawked its last and is no more.

It might be better to move the declaration into the if brace too

---
 net/wireless/reg.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/wireless/reg.c +1 -1
index 1ad04e5..7985ab2 100644
@@ -2192,7 +2192,6 @@ static void print_regdomain_info(const struct ieee80211_regdomain *rd)
 /* Takes ownership of rd only if it doesn't fail */
 static int __set_regdom(const struct ieee80211_regdomain *rd)
 {
-	const struct ieee80211_regdomain *intersected_rd = NULL;
 	struct cfg80211_registered_device *rdev = NULL;
 	struct wiphy *request_wiphy;
 	/* Some basic sanity checks first */
@@ -2282,6 +2281,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
 	/* Intersection requires a bit more work */
 
 	if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
+		const struct ieee80211_regdomain *intersected_rd;
 
 		intersected_rd = regdom_intersect(rd, cfg80211_regdomain);
 		if (!intersected_rd)
maintainer Applied
#2 lore raw
In reply to Alan Cox
Quoted 5 lines · Alan Cox

From: Alan Cox <[email protected]>

The only case where intersected_rd can become non NULL is within an if. All paths from that if return, so the end chunk has therefore squawked its last and is no more.

Ohh, a BUG_ON() gone, that makes me happy :-)

Applied, thanks.

johannes