aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/sis
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-05-25 05:34:52 -0400
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-08-19 04:34:52 -0400
commit8e42a962a279369ba3e6a25f321c7cd4d471e633 (patch)
treecd78fe85990ebca768f1235b5633ae3344386cdd /drivers/video/sis
parente1599cf8c7ab93cb4bbd67516f5c989211335df1 (diff)
sisfb: use display information in info not in var for panning
We must not use any information in the passed var besides xoffset, yoffset and vmode as otherwise applications might abuse it. Fix checkpatch.pl warnings in the surrounding code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'drivers/video/sis')
-rw-r--r--drivers/video/sis/sis_main.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index 75259845933d..078ca2167d6f 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -1333,19 +1333,14 @@ sisfb_set_base_CRT2(struct sis_video_info *ivideo, unsigned int base)
1333} 1333}
1334 1334
1335static int 1335static int
1336sisfb_pan_var(struct sis_video_info *ivideo, struct fb_var_screeninfo *var) 1336sisfb_pan_var(struct sis_video_info *ivideo, struct fb_info *info,
1337 struct fb_var_screeninfo *var)
1337{ 1338{
1338 if(var->xoffset > (var->xres_virtual - var->xres)) { 1339 ivideo->current_base = var->yoffset * info->var.xres_virtual
1339 return -EINVAL; 1340 + var->xoffset;
1340 }
1341 if(var->yoffset > (var->yres_virtual - var->yres)) {
1342 return -EINVAL;
1343 }
1344
1345 ivideo->current_base = (var->yoffset * var->xres_virtual) + var->xoffset;
1346 1341
1347 /* calculate base bpp dep. */ 1342 /* calculate base bpp dep. */
1348 switch(var->bits_per_pixel) { 1343 switch (info->var.bits_per_pixel) {
1349 case 32: 1344 case 32:
1350 break; 1345 break;
1351 case 16: 1346 case 16:
@@ -1635,20 +1630,15 @@ sisfb_pan_display(struct fb_var_screeninfo *var, struct fb_info* info)
1635 struct sis_video_info *ivideo = (struct sis_video_info *)info->par; 1630 struct sis_video_info *ivideo = (struct sis_video_info *)info->par;
1636 int err; 1631 int err;
1637 1632
1638 if(var->xoffset > (var->xres_virtual - var->xres)) 1633 if (var->vmode & FB_VMODE_YWRAP)
1639 return -EINVAL;
1640
1641 if(var->yoffset > (var->yres_virtual - var->yres))
1642 return -EINVAL;
1643
1644 if(var->vmode & FB_VMODE_YWRAP)
1645 return -EINVAL; 1634 return -EINVAL;
1646 1635
1647 if(var->xoffset + info->var.xres > info->var.xres_virtual || 1636 if (var->xoffset + info->var.xres > info->var.xres_virtual ||
1648 var->yoffset + info->var.yres > info->var.yres_virtual) 1637 var->yoffset + info->var.yres > info->var.yres_virtual)
1649 return -EINVAL; 1638 return -EINVAL;
1650 1639
1651 if((err = sisfb_pan_var(ivideo, var)) < 0) 1640 err = sisfb_pan_var(ivideo, info, var);
1641 if (err < 0)
1652 return err; 1642 return err;
1653 1643
1654 info->var.xoffset = var->xoffset; 1644 info->var.xoffset = var->xoffset;