Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c56b26a2 authored by Johannes Berg's avatar Johannes Berg Committed by Alistair Strachan
Browse files

BACKPORT: mac80211_hwsim: fix check for custom world regdom array size



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: default avatarDavid Binderman <dcb314@hotmail.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
(cherry picked from commit 5875755c577b00b06aba77ba471175c3e3a33c25)
[astrachan: minor rediff for context, goto vs return]
Bug: 70214720
Change-Id: I06426382cd449e36334ef3dd83af3cf6296da913
Signed-off-by: default avatarAlistair Strachan <astrachan@google.com>
parent 780c7e45
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2016,14 +2016,14 @@ static struct sk_buff *build_radio_msg(int cmd, 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)
				goto error;
			break;
		}
	}