diff options
author | Michal Januszewski <spock@gentoo.org> | 2009-03-31 18:25:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-01 11:59:33 -0400 |
commit | 23b736545473ed853b685cbc03883aa6ff3f0e0d (patch) | |
tree | dbc04a8fc5765f6832085909e6b5247511c33fed /drivers/video | |
parent | ddb53d48da5b0e691f35e703ac29118747f86c99 (diff) |
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#c37
Signed-off-by: Michal Januszewski <spock@gentoo.org>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/uvesafb.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c index c288270e42f7..0b370aebdbfd 100644 --- a/drivers/video/uvesafb.c +++ b/drivers/video/uvesafb.c | |||
@@ -850,14 +850,16 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info) | |||
850 | if (vbemode) { | 850 | if (vbemode) { |
851 | for (i = 0; i < par->vbe_modes_cnt; i++) { | 851 | for (i = 0; i < par->vbe_modes_cnt; i++) { |
852 | if (par->vbe_modes[i].mode_id == vbemode) { | 852 | if (par->vbe_modes[i].mode_id == vbemode) { |
853 | modeid = i; | ||
854 | uvesafb_setup_var(&info->var, info, | ||
855 | &par->vbe_modes[modeid]); | ||
853 | fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, | 856 | fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, |
854 | &info->var, info); | 857 | &info->var, info); |
855 | /* | 858 | /* |
856 | * With pixclock set to 0, the default BIOS | 859 | * With pixclock set to 0, the default BIOS |
857 | * timings will be used in set_par(). | 860 | * timings will be used in set_par(). |
858 | */ | 861 | */ |
859 | info->var.pixclock = 0; | 862 | info->var.pixclock = 0; |
860 | modeid = i; | ||
861 | goto gotmode; | 863 | goto gotmode; |
862 | } | 864 | } |
863 | } | 865 | } |
@@ -904,8 +906,11 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info) | |||
904 | fb_videomode_to_var(&info->var, mode); | 906 | fb_videomode_to_var(&info->var, mode); |
905 | } else { | 907 | } else { |
906 | modeid = par->vbe_modes[0].mode_id; | 908 | modeid = par->vbe_modes[0].mode_id; |
909 | uvesafb_setup_var(&info->var, info, | ||
910 | &par->vbe_modes[modeid]); | ||
907 | fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, | 911 | fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, |
908 | &info->var, info); | 912 | &info->var, info); |
913 | |||
909 | goto gotmode; | 914 | goto gotmode; |
910 | } | 915 | } |
911 | } | 916 | } |
@@ -917,9 +922,9 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info) | |||
917 | if (modeid == -1) | 922 | if (modeid == -1) |
918 | return -EINVAL; | 923 | return -EINVAL; |
919 | 924 | ||
920 | gotmode: | ||
921 | uvesafb_setup_var(&info->var, info, &par->vbe_modes[modeid]); | 925 | uvesafb_setup_var(&info->var, info, &par->vbe_modes[modeid]); |
922 | 926 | ||
927 | gotmode: | ||
923 | /* | 928 | /* |
924 | * If we are not VBE3.0+ compliant, we're done -- the BIOS will | 929 | * If we are not VBE3.0+ compliant, we're done -- the BIOS will |
925 | * ignore our timings anyway. | 930 | * ignore our timings anyway. |