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

pvr2fb: fix pseudo_palette array overrun and typecast

- the pseudo_palette has only 16 elements. Do not write if regno (the array
  index) is more than 15.
- if using generic drawing libraries, the typecast of pseudo_palette is
  always u32 *
Signed-off-by: default avatarAntonino Daplas <adaplas@gmail.com>
Acked-by: default avatarPaul Mundt <lethal@linux-sh.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 02c2c209
...@@ -333,24 +333,25 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red, ...@@ -333,24 +333,25 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
((blue & 0xf800) >> 11); ((blue & 0xf800) >> 11);
pvr2fb_set_pal_entry(par, regno, tmp); pvr2fb_set_pal_entry(par, regno, tmp);
((u16*)(info->pseudo_palette))[regno] = tmp;
break; break;
case 24: /* RGB 888 */ case 24: /* RGB 888 */
red >>= 8; green >>= 8; blue >>= 8; red >>= 8; green >>= 8; blue >>= 8;
((u32*)(info->pseudo_palette))[regno] = (red << 16) | (green << 8) | blue; tmp = (red << 16) | (green << 8) | blue;
break; break;
case 32: /* ARGB 8888 */ case 32: /* ARGB 8888 */
red >>= 8; green >>= 8; blue >>= 8; red >>= 8; green >>= 8; blue >>= 8;
tmp = (transp << 24) | (red << 16) | (green << 8) | blue; tmp = (transp << 24) | (red << 16) | (green << 8) | blue;
pvr2fb_set_pal_entry(par, regno, tmp); pvr2fb_set_pal_entry(par, regno, tmp);
((u32*)(info->pseudo_palette))[regno] = tmp;
break; break;
default: default:
pr_debug("Invalid bit depth %d?!?\n", info->var.bits_per_pixel); pr_debug("Invalid bit depth %d?!?\n", info->var.bits_per_pixel);
return 1; return 1;
} }
if (regno < 16)
((u32*)(info->pseudo_palette))[regno] = tmp;
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