]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/lcd.c
lcd: fix integer overflow in calculation of number of colors
[karo-tx-uboot.git] / common / lcd.c
index 22dcd097961a3ec68c14a79978e2a6c3d455aca4..e8c18aa0d842330c37e41708e1c7e14e4f069276 100644 (file)
@@ -26,7 +26,7 @@
 #ifdef CONFIG_LCD_LOGO
 #include <bmp_logo.h>
 #include <bmp_logo_data.h>
-#if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
+#if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP < LCD_COLOR16)
 #error Default Color Map overlaps with Logo Color Map
 #endif
 #endif
@@ -621,7 +621,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        hdr_size = get_unaligned_le16(&bmp->header.size);
        debug("hdr_size=%d, bmp_bpix=%d\n", hdr_size, bmp_bpix);
 
-       colors = 1 << bmp_bpix;
+       colors = 1ULL << bmp_bpix;
 
        bpix = NBITS(panel_info.vl_bpix);
 
@@ -644,8 +644,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                return 1;
        }
 
-       debug("Display-bmp: %lu x %lu  with %llu colors, display %d\n",
-               width, height, colors, NBITS(bmp_bpix));
+       debug("Display-bmp: %lu x %lu  with %llu colors, display %llu\n",
+               width, height, colors, 1ULL << bpix);
 
        if (bmp_bpix == 8)
                lcd_set_cmap(bmp, colors);
@@ -706,8 +706,6 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                                        *(uint16_t *)fb = val;
                                        bmap++;
                                        fb += sizeof(uint16_t) / sizeof(*fb);
-                               } else {
-                                       FB_PUT_BYTE(fb, bmap);
                                }
                        }
                        if (bpix > 8) {
@@ -732,7 +730,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                }
                break;
 #endif /* CONFIG_BMP_16BPP */
-#if defined(CONFIG_BMP_24BMP)
+#if defined(CONFIG_BMP_24BPP)
        case 24:
                for (i = 0; i < height; ++i) {
                        for (j = 0; j < width; j++) {