[U-Boot] [PATCH 1/1] lcd: avoid possible NULL dereference
Heinrich Schuchardt
xypron.glpk at gmx.de
Sun Jul 30 19:59:23 UTC 2017
Do not dereference bmp before the check if it is NULL.
The problem was indicated by cppcheck.
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
common/lcd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/lcd.c b/common/lcd.c
index 7e399cee2d..35914960a5 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -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);
--
2.13.2
More information about the U-Boot
mailing list