Skip to content

Commit

Permalink
sisfb: fix pseudo_palette array size and overrun
Browse files Browse the repository at this point in the history
- the pseudo_palette is only 16 elements long.
- do not write to the pseudo_palette if regno (array index) is more than 15.

Signed-off-by: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Antonino A. Daplas authored and Linus Torvalds committed Jul 17, 2007
1 parent c312f97 commit 000d533
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/video/sis/sis.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ struct sis_video_info {
struct fb_var_screeninfo default_var;

struct fb_fix_screeninfo sisfb_fix;
u32 pseudo_palette[17];
u32 pseudo_palette[16];

struct sisfb_monitor {
u16 hmin;
Expand Down
6 changes: 6 additions & 0 deletions drivers/video/sis/sis_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,12 +1405,18 @@ sisfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue,
}
break;
case 16:
if (regno >= 16)
break;

((u32 *)(info->pseudo_palette))[regno] =
(red & 0xf800) |
((green & 0xfc00) >> 5) |
((blue & 0xf800) >> 11);
break;
case 32:
if (regno >= 16)
break;

red >>= 8;
green >>= 8;
blue >>= 8;
Expand Down

0 comments on commit 000d533

Please sign in to comment.