fbcon: Fix boundary checks for fbcon=vc:n1-n2 parameters
[platform/kernel/linux-rpi.git] / drivers / video / fbdev / core / fbcon.c
index bb83e7c..c1362c1 100644 (file)
@@ -115,8 +115,8 @@ static int logo_lines;
    enums.  */
 static int logo_shown = FBCON_LOGO_CANSHOW;
 /* console mappings */
-static int first_fb_vc;
-static int last_fb_vc = MAX_NR_CONSOLES - 1;
+static unsigned int first_fb_vc;
+static unsigned int last_fb_vc = MAX_NR_CONSOLES - 1;
 static int fbcon_is_default = 1; 
 static int primary_device = -1;
 static int fbcon_has_console_bind;
@@ -464,10 +464,12 @@ static int __init fb_console_setup(char *this_opt)
                        options += 3;
                        if (*options)
                                first_fb_vc = simple_strtoul(options, &options, 10) - 1;
-                       if (first_fb_vc < 0)
+                       if (first_fb_vc >= MAX_NR_CONSOLES)
                                first_fb_vc = 0;
                        if (*options++ == '-')
                                last_fb_vc = simple_strtoul(options, &options, 10) - 1;
+                       if (last_fb_vc < first_fb_vc || last_fb_vc >= MAX_NR_CONSOLES)
+                               last_fb_vc = MAX_NR_CONSOLES - 1;
                        fbcon_is_default = 0; 
                        continue;
                }