Skip to content

Commit

Permalink
cyblafb: 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 <[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 Jul 17, 2007
1 parent 1149454 commit 7592181
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions drivers/video/cyblafb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,15 +1068,18 @@ static int cyblafb_setcolreg(unsigned regno, unsigned red, unsigned green,
out8(0x3C9, green >> 10);
out8(0x3C9, blue >> 10);

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

return 0;
}
Expand Down

0 comments on commit 7592181

Please sign in to comment.