Browse Source

fbcon: Fix option parsing control flow in fb_console_setup

Since strsep is used to tokenize the options string, after each option
match the code should use "continue" to get the next token from strsep.
This patch applies this pattern consistently.

Previously, for "scrollback:" and "map:" the parse code would return
(unconditionally: strsep ensures *options != ','), causing any
following option to be ignored, while for "vc:" the parse code would
go on to parse further options within the same token, which could lead
to invalid input being accepted.

Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
Acked-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Maarten ter Huurne 11 years ago
parent
commit
37773c4e7f
1 changed files with 9 additions and 10 deletions
  1. 9 10
      drivers/video/console/fbcon.c

+ 9 - 10
drivers/video/console/fbcon.c

@@ -448,8 +448,10 @@ static int __init fb_console_setup(char *this_opt)
 		return 1;
 		return 1;
 
 
 	while ((options = strsep(&this_opt, ",")) != NULL) {
 	while ((options = strsep(&this_opt, ",")) != NULL) {
-		if (!strncmp(options, "font:", 5))
+		if (!strncmp(options, "font:", 5)) {
 			strlcpy(fontname, options + 5, sizeof(fontname));
 			strlcpy(fontname, options + 5, sizeof(fontname));
+			continue;
+		}
 		
 		
 		if (!strncmp(options, "scrollback:", 11)) {
 		if (!strncmp(options, "scrollback:", 11)) {
 			options += 11;
 			options += 11;
@@ -457,13 +459,9 @@ static int __init fb_console_setup(char *this_opt)
 				fbcon_softback_size = simple_strtoul(options, &options, 0);
 				fbcon_softback_size = simple_strtoul(options, &options, 0);
 				if (*options == 'k' || *options == 'K') {
 				if (*options == 'k' || *options == 'K') {
 					fbcon_softback_size *= 1024;
 					fbcon_softback_size *= 1024;
-					options++;
 				}
 				}
-				if (*options != ',')
-					return 1;
-				options++;
-			} else
-				return 1;
+			}
+			continue;
 		}
 		}
 		
 		
 		if (!strncmp(options, "map:", 4)) {
 		if (!strncmp(options, "map:", 4)) {
@@ -478,8 +476,7 @@ static int __init fb_console_setup(char *this_opt)
 
 
 				fbcon_map_override();
 				fbcon_map_override();
 			}
 			}
-
-			return 1;
+			continue;
 		}
 		}
 
 
 		if (!strncmp(options, "vc:", 3)) {
 		if (!strncmp(options, "vc:", 3)) {
@@ -491,7 +488,8 @@ static int __init fb_console_setup(char *this_opt)
 			if (*options++ == '-')
 			if (*options++ == '-')
 				last_fb_vc = simple_strtoul(options, &options, 10) - 1;
 				last_fb_vc = simple_strtoul(options, &options, 10) - 1;
 			fbcon_is_default = 0; 
 			fbcon_is_default = 0; 
-		}	
+			continue;
+		}
 
 
 		if (!strncmp(options, "rotate:", 7)) {
 		if (!strncmp(options, "rotate:", 7)) {
 			options += 7;
 			options += 7;
@@ -499,6 +497,7 @@ static int __init fb_console_setup(char *this_opt)
 				initial_rotation = simple_strtoul(options, &options, 0);
 				initial_rotation = simple_strtoul(options, &options, 0);
 			if (initial_rotation > 3)
 			if (initial_rotation > 3)
 				initial_rotation = 0;
 				initial_rotation = 0;
+			continue;
 		}
 		}
 	}
 	}
 	return 1;
 	return 1;