[PATCH] fbdev: Fix crash if fb_set_var() called before register_framebuffer()

From: Antonino A. Daplas
Date: Wed Nov 24 2004 - 12:32:03 EST


The field info->modelist is initialized during register_framebuffer. This
field is also referred to in fb_set_var(). Thus a call to fb_set_var()
before register_framebuffer() will cause a crash. A few drivers do this,
notably controlfb. (This might fix reports of controlfb crashing in
powermacs).

Signed-off-by: Antonino Daplas <adaplas@xxxxxxx>
---

fbmem.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)

diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
--- a/drivers/video/fbmem.c 2004-11-23 21:20:13 +08:00
+++ b/drivers/video/fbmem.c 2004-11-25 01:09:22 +08:00
@@ -725,7 +725,10 @@
fb_set_cmap(&info->cmap, info);

fb_var_to_videomode(&mode, &info->var);
- fb_add_videomode(&mode, &info->modelist);
+
+ if (info->modelist.prev && info->modelist.next &&
+ !list_empty(&info->modelist))
+ fb_add_videomode(&mode, &info->modelist);

if (info->flags & FBINFO_MISC_MODECHANGEUSER) {
struct fb_event event;




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/