Skip to content

Commit

Permalink
cfg80211: make rdev assignment clearer in nl80211_testmode_dump()
Browse files Browse the repository at this point in the history
Avoid assigning rdev to NULL when we already have it and getting it
again from the wiphy index, by moving this code to relevant if block.

Signed-off-by: Luca Coelho <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
lucacoelho authored and jmberg-intel committed Feb 8, 2017
1 parent b2347a3 commit a4956dc
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -8585,6 +8585,12 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
* so we need to offset by 1.
*/
phy_idx = cb->args[0] - 1;

rdev = cfg80211_rdev_by_wiphy_idx(phy_idx);
if (!rdev) {
err = -ENOENT;
goto out_err;
}
} else {
struct nlattr **attrbuf = genl_family_attrbuf(&nl80211_fam);

Expand All @@ -8599,7 +8605,6 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
goto out_err;
}
phy_idx = rdev->wiphy_idx;
rdev = NULL;

if (attrbuf[NL80211_ATTR_TESTDATA])
cb->args[1] = (long)attrbuf[NL80211_ATTR_TESTDATA];
Expand All @@ -8610,12 +8615,6 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
data_len = nla_len((void *)cb->args[1]);
}

rdev = cfg80211_rdev_by_wiphy_idx(phy_idx);
if (!rdev) {
err = -ENOENT;
goto out_err;
}

if (!rdev->ops->testmode_dump) {
err = -EOPNOTSUPP;
goto out_err;
Expand Down

0 comments on commit a4956dc

Please sign in to comment.