diff options
| author | Petr Vandrovec <vandrove@vc.cvut.cz> | 2002-06-30 01:43:24 -0700 |
|---|---|---|
| committer | Petr Vandrovec <vandrove@vc.cvut.cz> | 2002-06-30 01:43:24 -0700 |
| commit | 623568bf07832b0055d2c9b4ff4edb52dfaabf9f (patch) | |
| tree | cf2f2ed795d1bfa93129a4e6b63bed946bb37640 /drivers | |
| parent | 634703d8a9011fd8049e493be65a08e9dd4a867b (diff) | |
[PATCH] 2.5.24 matroxfb memory corruption
When James converted all drivers to unified do_install_cmap(), he
blindly changed also matroxfb, which happily uses fbcon.currcon == -1.
This caused memory corruption because of memory before fb_display[]
array was overwritten.
Default do_install_cmap() also installed invalid default color map in
some matroxfb resolutions. Not all world have >= 4bpp.
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/video/matrox/matroxfb_base.c | 15 | ||||
| -rw-r--r-- | drivers/video/matrox/matroxfb_crtc2.c | 15 |
2 files changed, 28 insertions, 2 deletions
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c index 431a2896ce25..8bc67da400b1 100644 --- a/drivers/video/matrox/matroxfb_base.c +++ b/drivers/video/matrox/matroxfb_base.c @@ -141,6 +141,19 @@ static struct fb_var_screeninfo vesafb_defined = { /* --------------------------------------------------------------------- */ +static inline void my_install_cmap(WPMINFO2) +{ + /* Do not touch this code if you do not understand what it does! */ + /* Never try to use do_install_cmap() instead. It is crap. */ + struct fb_cmap* cmap = &ACCESS_FBINFO(currcon_display)->cmap; + + if (cmap->len) + fb_set_cmap(cmap, 1, &ACCESS_FBINFO(fbcon)); + else + fb_set_cmap(fb_default_cmap(ACCESS_FBINFO(curr.cmap_len)), + 1, &ACCESS_FBINFO(fbcon)); +} + static void matrox_pan_var(WPMINFO struct fb_var_screeninfo *var) { unsigned int pos; @@ -869,7 +882,7 @@ static int matroxfb_set_var(struct fb_var_screeninfo *var, int con, up_read(&ACCESS_FBINFO(altout.lock)); } matrox_cfbX_init(PMINFO display); - do_install_cmap(ACCESS_FBINFO(fbcon.currcon),&ACCESS_FBINFO(fbcon)); + my_install_cmap(PMINFO2); #if defined(CONFIG_FB_COMPAT_XPMAC) if (console_fb_info == &ACCESS_FBINFO(fbcon)) { int vmode, cmode; diff --git a/drivers/video/matrox/matroxfb_crtc2.c b/drivers/video/matrox/matroxfb_crtc2.c index ac0817a257fc..1ec60bb05531 100644 --- a/drivers/video/matrox/matroxfb_crtc2.c +++ b/drivers/video/matrox/matroxfb_crtc2.c @@ -84,6 +84,19 @@ static int matroxfb_dh_setcolreg(unsigned regno, unsigned red, unsigned green, #undef m2info } +static inline void my_install_cmap(struct matroxfb_dh_fb_info* m2info) +{ + /* Do not touch this code if you do not understand what it does! */ + /* Never try to use do_install_cmap() instead. It is crap. */ + struct fb_cmap* cmap = &m2info->currcon_display->cmap; + + if (cmap->len) + fb_set_cmap(cmap, 1, &m2info->fbcon); + else + fb_set_cmap(fb_default_cmap(16), 1, &m2info->fbcon); +} + + static void matroxfb_dh_restore(struct matroxfb_dh_fb_info* m2info, struct my_timming* mt, struct display* p, @@ -439,7 +452,7 @@ static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con, up_read(&ACCESS_FBINFO(altout.lock)); } matroxfb_dh_cfbX_init(m2info, p); - do_install_cmap(ACCESS_FBINFO(fbcon.currcon), &ACCESS_FBINFO(fbcon)); + my_install_cmap(m2info); } return 0; #undef m2info |
