sisfb: fix pseudo_palette array size and overrun
authorAntonino A. Daplas <adaplas@gmail.com>
Tue, 17 Jul 2007 11:05:44 +0000 (04:05 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 17 Jul 2007 17:23:13 +0000 (10:23 -0700)
- the pseudo_palette is only 16 elements long.
- do not write to the pseudo_palette if regno (array index) is more than 15.

Signed-off-by: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/video/sis/sis.h
drivers/video/sis/sis_main.c

index d5e2d9c27847d5e261d89c2419ecddcdc9e7f919..d53bf6945f0c9b427df8a07dc0c3add81fe48d8d 100644 (file)
@@ -479,7 +479,7 @@ struct sis_video_info {
        struct fb_var_screeninfo default_var;
 
        struct fb_fix_screeninfo sisfb_fix;
-       u32             pseudo_palette[17];
+       u32             pseudo_palette[16];
 
        struct sisfb_monitor {
                u16 hmin;
index 93d07ef852762e8d9198adc1d1a3e03a93f8a1ed..e8ccace01252afe2dadebcb3a74cce85fe0ae5f1 100644 (file)
@@ -1405,12 +1405,18 @@ sisfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue,
                }
                break;
        case 16:
+               if (regno >= 16)
+                       break;
+
                ((u32 *)(info->pseudo_palette))[regno] =
                                (red & 0xf800)          |
                                ((green & 0xfc00) >> 5) |
                                ((blue & 0xf800) >> 11);
                break;
        case 32:
+               if (regno >= 16)
+                       break;
+
                red >>= 8;
                green >>= 8;
                blue >>= 8;