airo: Reorder tests, check bounds before element
authorRoel Kluin <roel.kluin@gmail.com>
Mon, 26 Oct 2009 14:28:11 +0000 (15:28 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 27 Oct 2009 20:29:49 +0000 (16:29 -0400)
Test whether index is within bounds before reading the element

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/airo.c

index 7116a1a..abf896a 100644 (file)
@@ -4790,9 +4790,8 @@ static int proc_stats_rid_open( struct inode *inode,
 static int get_dec_u16( char *buffer, int *start, int limit ) {
        u16 value;
        int valid = 0;
-       for( value = 0; buffer[*start] >= '0' &&
-                    buffer[*start] <= '9' &&
-                    *start < limit; (*start)++ ) {
+       for (value = 0; *start < limit && buffer[*start] >= '0' &&
+                       buffer[*start] <= '9'; (*start)++) {
                valid = 1;
                value *= 10;
                value += buffer[*start] - '0';