common/lcd: add protection from null bmp pointer
authorNikita Kiryanov <nikita@compulab.co.il>
Sun, 19 Aug 2012 19:32:30 +0000 (19:32 +0000)
committerAnatolij Gustschin <agust@denx.de>
Fri, 21 Sep 2012 21:41:56 +0000 (23:41 +0200)
If the bmp pointer is null then U-Boot will get stuck when trying
to load the image.
What's worse, it will get stuck before the U-Boot shell becomes
available to the user, thus making it difficult to correct the
situation.

To protect from the above scenario, check if the pointer is valid.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
common/lcd.c

index 88dfa51d779c76b097528235e941102076eaa1b6..fcc09ac7a8609229936881bf8232dcc655cb9e9f 100644 (file)
@@ -674,7 +674,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        unsigned long pwidth = panel_info.vl_col;
        unsigned colors, bpix, bmp_bpix;
 
-       if (!((bmp->header.signature[0] == 'B') &&
+       if (!bmp || !((bmp->header.signature[0] == 'B') &&
                (bmp->header.signature[1] == 'M'))) {
                printf("Error: no valid bmp image at %lx\n", bmp_image);