]> err.no Git - linux-2.6/commitdiff
cyblafb: fix pseudo_palette array overrun in setcolreg
authorAntonino A. Daplas <adaplas@gmail.com>
Tue, 17 Jul 2007 11:05:35 +0000 (04:05 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 17 Jul 2007 17:23:12 +0000 (10:23 -0700)
The pseudo_palette has only 16 elements. Do not write if regno (the 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/cyblafb.c

index 94a66c2d2cf528a7f9f31c1c209ef3841f6433a1..e23324d10be269cf60767e2a486de897e39edb37 100644 (file)
@@ -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;
 }