mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 11:19:37 +00:00
fbdev: add palette register check to several drivers
Add check if palette register number is in correct range for few drivers which miss it. The regno value comes indirectly from user space. Two drivers has converted check from BUG_ON() macro to just return an error (non-zero value). Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
2cb96f8662
commit
2f390380ca
5 changed files with 12 additions and 2 deletions
|
@ -2245,6 +2245,9 @@ static int ext_setcolreg(unsigned int regno, unsigned int red,
|
||||||
if (regno > 255)
|
if (regno > 255)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (regno > 255)
|
||||||
|
return 1;
|
||||||
|
|
||||||
switch (external_card_type) {
|
switch (external_card_type) {
|
||||||
case IS_VGA:
|
case IS_VGA:
|
||||||
OUTB(0x3c8, regno);
|
OUTB(0x3c8, regno);
|
||||||
|
|
|
@ -358,6 +358,8 @@ static int ep93xxfb_setcolreg(unsigned int regno, unsigned int red,
|
||||||
|
|
||||||
switch (info->fix.visual) {
|
switch (info->fix.visual) {
|
||||||
case FB_VISUAL_PSEUDOCOLOR:
|
case FB_VISUAL_PSEUDOCOLOR:
|
||||||
|
if (regno > 255)
|
||||||
|
return 1;
|
||||||
rgb = ((red & 0xff00) << 8) | (green & 0xff00) |
|
rgb = ((red & 0xff00) << 8) | (green & 0xff00) |
|
||||||
((blue & 0xff00) >> 8);
|
((blue & 0xff00) >> 8);
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,9 @@ static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
|
||||||
/* value to be written into the palette reg. */
|
/* value to be written into the palette reg. */
|
||||||
unsigned long hw_colorvalue = 0;
|
unsigned long hw_colorvalue = 0;
|
||||||
|
|
||||||
|
if (regno > 255)
|
||||||
|
return 1;
|
||||||
|
|
||||||
red >>= 8; /* The cmap fields are 16 bits */
|
red >>= 8; /* The cmap fields are 16 bits */
|
||||||
green >>= 8; /* wide, but the harware colormap */
|
green >>= 8; /* wide, but the harware colormap */
|
||||||
blue >>= 8; /* registers are only 8 bits wide */
|
blue >>= 8; /* registers are only 8 bits wide */
|
||||||
|
|
|
@ -98,7 +98,8 @@ static int pmagbafb_setcolreg(unsigned int regno, unsigned int red,
|
||||||
{
|
{
|
||||||
struct pmagbafb_par *par = info->par;
|
struct pmagbafb_par *par = info->par;
|
||||||
|
|
||||||
BUG_ON(regno >= info->cmap.len);
|
if (regno >= info->cmap.len)
|
||||||
|
return 1;
|
||||||
|
|
||||||
red >>= 8; /* The cmap fields are 16 bits */
|
red >>= 8; /* The cmap fields are 16 bits */
|
||||||
green >>= 8; /* wide, but the hardware colormap */
|
green >>= 8; /* wide, but the hardware colormap */
|
||||||
|
|
|
@ -102,7 +102,8 @@ static int pmagbbfb_setcolreg(unsigned int regno, unsigned int red,
|
||||||
{
|
{
|
||||||
struct pmagbbfb_par *par = info->par;
|
struct pmagbbfb_par *par = info->par;
|
||||||
|
|
||||||
BUG_ON(regno >= info->cmap.len);
|
if (regno >= info->cmap.len)
|
||||||
|
return 1;
|
||||||
|
|
||||||
red >>= 8; /* The cmap fields are 16 bits */
|
red >>= 8; /* The cmap fields are 16 bits */
|
||||||
green >>= 8; /* wide, but the hardware colormap */
|
green >>= 8; /* wide, but the hardware colormap */
|
||||||
|
|
Loading…
Reference in a new issue