]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
lcd: avoid possible NULL dereference
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>
Sun, 30 Jul 2017 19:59:23 +0000 (21:59 +0200)
committerAnatolij Gustschin <agust@denx.de>
Sat, 19 Aug 2017 18:42:20 +0000 (20:42 +0200)
Do not dereference bmp before the check if it is NULL.

The problem was indicated by cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
common/lcd.c

index c3ff9599ed89cc0e03d60d8ff9a63f44c0e5afd1..4b3d7dcd34b82bf6c0dce9409b557723372c854a 100644 (file)
@@ -578,7 +578,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        unsigned long pwidth = panel_info.vl_col;
        unsigned colors, bpix, bmp_bpix;
        int hdr_size;
-       struct bmp_color_table_entry *palette = bmp->color_table;
+       struct bmp_color_table_entry *palette;
 
        if (!bmp || !(bmp->header.signature[0] == 'B' &&
                bmp->header.signature[1] == 'M')) {
@@ -587,6 +587,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                return 1;
        }
 
+       palette = bmp->color_table;
        width = get_unaligned_le32(&bmp->header.width);
        height = get_unaligned_le32(&bmp->header.height);
        bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);