Skip to contentSkip to conversation

rndis_wlan: use ARRAY_SIZE instead of sizeof when adding 11g rates

PATCH New Jussi Kivilinna 1 participant 2 messages May 27, 2008 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 rndis_wlan: use ARRAY_SIZE instead of sizeof when adding 11g rates

From: Scott Ashcroft <[email protected]>

While figuring out the TKIP problem I found a bug in the code which adds the 11g rates. It's using sizeof instead of ARRAY_SIZE to terminate the for loop. This makes it fall off the end of the rates array start into the frequency array instead. Running "iwlist rate" should show the problem as there will always be 32 rates with the last few being bogus.

The following patch will fix it.

---

 drivers/net/wireless/rndis_wlan.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/rndis_wlan.c +1 -1
index d0b1fb1..ed310f8 100644
@@ -1108,7 +1108,7 @@ static int rndis_iw_get_range(struct net_device *dev,
 	/* fill in 802.11g rates */
 	if (has_80211g_rates) {
 		num = range->num_bitrates;
-		for (i = 0; i < sizeof(rates_80211g); i++) {
+		for (i = 0; i < ARRAY_SIZE(rates_80211g); i++) {
 			for (j = 0; j < num; j++) {
 				if (range->bitrate[j] ==
 					rates_80211g[i] * 1000000)
#1 lore raw

PATCH 2/2 rndis_wlan: add missing range check for power_output modparam

Range check for power_output were missing.

---

 drivers/net/wireless/rndis_wlan.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/net/wireless/rndis_wlan.c +5 -0
index ed310f8..f7cca7d 100644
@@ -2414,6 +2414,11 @@ static int bcm4320_early_init(struct usbnet *dev)
 	else if (priv->param_power_save > 2)
 		priv->param_power_save = 2;
 
+	if (priv->param_power_output < 0)
+		priv->param_power_output = 0;
+	else if (priv->param_power_output > 3)
+		priv->param_power_output = 3;
+
 	if (priv->param_roamtrigger < -80)
 		priv->param_roamtrigger = -80;
 	else if (priv->param_roamtrigger > -60)