Skip to content

Commit

Permalink
[PATCH] Fix pseudo_palette setup in asiliantfb_setcolreg()
Browse files Browse the repository at this point in the history
The setcolreg function will attempt to write 24 color entries to the
pseudo_pallette.  However, the pseudo_palette has only space for 16 entries.

Thanks to Atsushi Nemoto for reporting this bug.

Signed-off-by: Antonino Daplas <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
adaplas authored and Linus Torvalds committed Feb 24, 2006
1 parent cacfc8c commit ee71305
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions drivers/video/asiliantfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,32 +322,29 @@ static int asiliantfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
writeb(green, mmio_base + 0x791);
writeb(blue, mmio_base + 0x791);

switch(p->var.bits_per_pixel) {
case 15:
if (regno < 16) {
if (regno < 16) {
switch(p->var.red.offset) {
case 10: /* RGB 555 */
((u32 *)(p->pseudo_palette))[regno] =
((red & 0xf8) << 7) |
((green & 0xf8) << 2) |
((blue & 0xf8) >> 3);
}
break;
case 16:
if (regno < 16) {
break;
case 11: /* RGB 565 */
((u32 *)(p->pseudo_palette))[regno] =
((red & 0xf8) << 8) |
((green & 0xfc) << 3) |
((blue & 0xf8) >> 3);
}
break;
case 24:
if (regno < 24) {
break;
case 16: /* RGB 888 */
((u32 *)(p->pseudo_palette))[regno] =
(red << 16) |
(green << 8) |
(blue);
break;
}
break;
}

return 0;
}

Expand Down

0 comments on commit ee71305

Please sign in to comment.