Commit d3015247 authored by Antonino A. Daplas's avatar Antonino A. Daplas Committed by Linus Torvalds

[PATCH] intelfb: Fix buffer overrun

The pseudo_palette has room only for 16 entries, but intelfb_setcolreg will
attempt to write more.

Coverity Bug 558
Signed-off-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8d57f221
...@@ -1333,9 +1333,7 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, ...@@ -1333,9 +1333,7 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
if (regno > 255) if (regno > 255)
return 1; return 1;
switch (dinfo->depth) { if (dinfo->depth == 8) {
case 8:
{
red >>= 8; red >>= 8;
green >>= 8; green >>= 8;
blue >>= 8; blue >>= 8;
...@@ -1343,7 +1341,9 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, ...@@ -1343,7 +1341,9 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
intelfbhw_setcolreg(dinfo, regno, red, green, blue, intelfbhw_setcolreg(dinfo, regno, red, green, blue,
transp); transp);
} }
break;
if (regno < 16) {
switch (dinfo->depth) {
case 15: case 15:
dinfo->pseudo_palette[regno] = ((red & 0xf800) >> 1) | dinfo->pseudo_palette[regno] = ((red & 0xf800) >> 1) |
((green & 0xf800) >> 6) | ((green & 0xf800) >> 6) |
...@@ -1360,6 +1360,8 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, ...@@ -1360,6 +1360,8 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
((blue & 0xff00) >> 8); ((blue & 0xff00) >> 8);
break; break;
} }
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment