Skip to contentSkip to conversation

rtxxxx/sta_ioctl: rate_index one too large

PATCH New Roel Kluin 1 participant 1 message Nov 10, 2009 Staging

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 rtxxxx/sta_ioctl: rate_index one too large

`rate_count' is the size of ralinkrate[]. So an index that equals rate_count is one too large.

---
 drivers/staging/rt2860/sta_ioctl.c |    4 ++--
 drivers/staging/rt3090/sta_ioctl.c |   10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rt2860/sta_ioctl.c +2 -2
index c0e0425..5344616 100644
@@ -2572,8 +2572,8 @@ int rt_ioctl_giwrate(struct net_device *dev,
     if (rate_index < 0)
         rate_index = 0;
 
-    if (rate_index > rate_count)
-        rate_index = rate_count;
+    if (rate_index >= rate_count)
+        rate_index = rate_count - 1;
 
     wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
     wrqu->bitrate.disabled = 0;
drivers/staging/rt3090/sta_ioctl.c +5 -5
index b8ab84a..a314cbb 100644
@@ -1409,8 +1409,8 @@ int rt_ioctl_giwscan(struct net_device *dev,
 				int rate_index = 12 + ((UCHAR)capInfo.ChannelWidth * 24) + ((UCHAR)shortGI *48) + ((UCHAR)maxMCS);
 				if (rate_index < 0)
 					rate_index = 0;
-				if (rate_index > rate_count)
-					rate_index = rate_count;
+				if (rate_index >= rate_count)
+					rate_index = rate_count - 1;
 				iwe.u.bitrate.value	=  ralinkrate[rate_index] * 500000;
 			}
 
@@ -3163,8 +3163,8 @@ int rt_ioctl_giwrate(struct net_device *dev,
     if (rate_index < 0)
         rate_index = 0;
 
-    if (rate_index > rate_count)
-        rate_index = rate_count;
+    if (rate_index >= rate_count)
+        rate_index = rate_count - 1;
 
     wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
     wrqu->bitrate.disabled = 0;
@@ -7554,4 +7554,4 @@ INT	Set_Antenna_Proc(
 
 	return TRUE;
 }
-#endif // ANT_DIVERSITY_SUPPORT //
\ No newline at end of file
+#endif // ANT_DIVERSITY_SUPPORT //