From: Stanislaw Gruszka Date: Thu, 16 Oct 2008 05:03:43 +0000 (-0700) Subject: atmel_lcdfb: disallow setting larger resolution than the framebuffer memory can handle X-Git-Tag: v2.6.28-rc1~387 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=f928ac0a9810d46c8ba3bde7c969984340da9f5d;p=linux-2.6-omap-h63xx.git atmel_lcdfb: disallow setting larger resolution than the framebuffer memory can handle Signed-off-by: Stanislaw Gruszka Acked-by: Nicolas Ferre Cc: Krzysztof Helt Cc: Haavard Skinnemoen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index d38fd521742..f8d0a57a07c 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -372,6 +372,13 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, var->transp.offset = var->transp.length = 0; var->xoffset = var->yoffset = 0; + if (info->fix.smem_len) { + unsigned int smem_len = (var->xres_virtual * var->yres_virtual + * ((var->bits_per_pixel + 7) / 8)); + if (smem_len > info->fix.smem_len) + return -EINVAL; + } + /* Saturate vertical and horizontal timings at maximum values */ var->vsync_len = min_t(u32, var->vsync_len, (ATMEL_LCDC_VPW >> ATMEL_LCDC_VPW_OFFSET) + 1);