Commit 23b73654 authored by Michal Januszewski's avatar Michal Januszewski Committed by Linus Torvalds

uvesafb: fix selecting mode with the vbemode option

If the vbemode option is used, uvesafb calls fb_get_mode() without first
setting the resolution in info->var.  This results in a division by zero
in fb_get_mode(), as evidenced e.g.  in [1].  Fix this by ensuring the
info->var structure is populated before fb_get_mode() is called.

[1] http://bugzilla.kernel.org/show_bug.cgi?id=11661#c37Signed-off-by: default avatarMichal Januszewski <spock@gentoo.org>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ddb53d48
...@@ -850,14 +850,16 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info) ...@@ -850,14 +850,16 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info)
if (vbemode) { if (vbemode) {
for (i = 0; i < par->vbe_modes_cnt; i++) { for (i = 0; i < par->vbe_modes_cnt; i++) {
if (par->vbe_modes[i].mode_id == vbemode) { if (par->vbe_modes[i].mode_id == vbemode) {
modeid = i;
uvesafb_setup_var(&info->var, info,
&par->vbe_modes[modeid]);
fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60,
&info->var, info); &info->var, info);
/* /*
* With pixclock set to 0, the default BIOS * With pixclock set to 0, the default BIOS
* timings will be used in set_par(). * timings will be used in set_par().
*/ */
info->var.pixclock = 0; info->var.pixclock = 0;
modeid = i;
goto gotmode; goto gotmode;
} }
} }
...@@ -904,8 +906,11 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info) ...@@ -904,8 +906,11 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info)
fb_videomode_to_var(&info->var, mode); fb_videomode_to_var(&info->var, mode);
} else { } else {
modeid = par->vbe_modes[0].mode_id; modeid = par->vbe_modes[0].mode_id;
uvesafb_setup_var(&info->var, info,
&par->vbe_modes[modeid]);
fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60,
&info->var, info); &info->var, info);
goto gotmode; goto gotmode;
} }
} }
...@@ -917,9 +922,9 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info) ...@@ -917,9 +922,9 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info)
if (modeid == -1) if (modeid == -1)
return -EINVAL; return -EINVAL;
gotmode:
uvesafb_setup_var(&info->var, info, &par->vbe_modes[modeid]); uvesafb_setup_var(&info->var, info, &par->vbe_modes[modeid]);
gotmode:
/* /*
* If we are not VBE3.0+ compliant, we're done -- the BIOS will * If we are not VBE3.0+ compliant, we're done -- the BIOS will
* ignore our timings anyway. * ignore our timings anyway.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment