diff options
author | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2011-06-06 01:27:34 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-11 09:36:13 -0800 |
commit | 76ec8cdcca9f8fa8e2546ed96a2715a6654487ad (patch) | |
tree | b4066d555e694fa042d610477f6b7aeeab9f80d8 /drivers/video/via/viafbdev.c | |
parent | cdf3e3448744d14b6307dfc7f7203cba6fecf199 (diff) | |
download | kernel_samsung_smdk4412-76ec8cdcca9f8fa8e2546ed96a2715a6654487ad.zip kernel_samsung_smdk4412-76ec8cdcca9f8fa8e2546ed96a2715a6654487ad.tar.gz kernel_samsung_smdk4412-76ec8cdcca9f8fa8e2546ed96a2715a6654487ad.tar.bz2 |
viafb: improve pitch handling
commit 936a3f770b8de7042d793272f008ef1bb08522e9 upstream.
This patch adds checks for minimum and maximum pitch size to prevent
invalid settings which could otherwise crash the machine. Also the
alignment is done in a slightly more readable way.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/video/via/viafbdev.c')
-rw-r--r-- | drivers/video/via/viafbdev.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c index 518f3ff..dd1276e 100644 --- a/drivers/video/via/viafbdev.c +++ b/drivers/video/via/viafbdev.c @@ -151,7 +151,8 @@ static void viafb_update_fix(struct fb_info *info) info->fix.visual = bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; - info->fix.line_length = (info->var.xres_virtual * bpp / 8 + 7) & ~7; + info->fix.line_length = ALIGN(info->var.xres_virtual * bpp / 8, + VIA_PITCH_SIZE); } static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix, @@ -238,8 +239,12 @@ static int viafb_check_var(struct fb_var_screeninfo *var, depth = 24; viafb_fill_var_color_info(var, depth); - line = (var->xres_virtual * var->bits_per_pixel / 8 + 7) & ~7; - if (line * var->yres_virtual > ppar->memsize) + if (var->xres_virtual < var->xres) + var->xres_virtual = var->xres; + + line = ALIGN(var->xres_virtual * var->bits_per_pixel / 8, + VIA_PITCH_SIZE); + if (line > VIA_PITCH_MAX || line * var->yres_virtual > ppar->memsize) return -EINVAL; /* Based on var passed in to calculate the refresh, |