Skip to content

Commit

Permalink
mac80211_hwsim: fix check for custom world regdom array size
Browse files Browse the repository at this point in the history
David Binderman reports that the conditions in the first loop
are the wrong way around - checking the array contents before
the size.

Instead of leaving the empty loop there and reordering the two
checks unify it into a single loop that skips over non-matches
and exits after the first match.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Johannes Berg committed Dec 22, 2014
1 parent 8d819a9 commit 5875755
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/net/wireless/mac80211_hwsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -2150,14 +2150,14 @@ static int append_radio_msg(struct sk_buff *skb, int id,
if (param->regd) {
int i;

for (i = 0; hwsim_world_regdom_custom[i] != param->regd &&
i < ARRAY_SIZE(hwsim_world_regdom_custom); i++)
;
for (i = 0; i < ARRAY_SIZE(hwsim_world_regdom_custom); i++) {
if (hwsim_world_regdom_custom[i] != param->regd)
continue;

if (i < ARRAY_SIZE(hwsim_world_regdom_custom)) {
ret = nla_put_u32(skb, HWSIM_ATTR_REG_CUSTOM_REG, i);
if (ret < 0)
return ret;
break;
}
}

Expand Down

0 comments on commit 5875755

Please sign in to comment.