Skip to content

Commit

Permalink
tridentfb: fix pseudo_palette array overrun in setcolreg
Browse files Browse the repository at this point in the history
The pseudo_palette has only 16 elements. Do not write if regno (the 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 eb3daa8 commit 973d9ab
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions drivers/video/tridentfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,27 +976,29 @@ static int tridentfb_setcolreg(unsigned regno, unsigned red, unsigned green,
return 1;


if (bpp==8) {
if (bpp == 8) {
t_outb(0xFF,0x3C6);
t_outb(regno,0x3C8);

t_outb(red>>10,0x3C9);
t_outb(green>>10,0x3C9);
t_outb(blue>>10,0x3C9);

} else if (bpp == 16) { /* RGB 565 */
u32 col;

col = (red & 0xF800) | ((green & 0xFC00) >> 5) |
((blue & 0xF800) >> 11);
col |= col << 16;
((u32 *)(info->pseudo_palette))[regno] = col;
} else if (bpp == 32) /* ARGB 8888 */
((u32*)info->pseudo_palette)[regno] =
((transp & 0xFF00) <<16) |
((red & 0xFF00) << 8) |
((green & 0xFF00)) |
((blue & 0xFF00)>>8);
} else if (regno < 16) {
if (bpp == 16) { /* RGB 565 */
u32 col;

col = (red & 0xF800) | ((green & 0xFC00) >> 5) |
((blue & 0xF800) >> 11);
col |= col << 16;
((u32 *)(info->pseudo_palette))[regno] = col;
} else if (bpp == 32) /* ARGB 8888 */
((u32*)info->pseudo_palette)[regno] =
((transp & 0xFF00) <<16) |
((red & 0xFF00) << 8) |
((green & 0xFF00)) |
((blue & 0xFF00)>>8);
}

// debug("exit\n");
return 0;
Expand Down

0 comments on commit 973d9ab

Please sign in to comment.