common/lcd: add protection from null bmp pointer
PATCH 1/1 common/lcd: add protection from null bmp pointer
If the bmp pointer is null (for example because the environment variable "splashimage" was not defined) 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.
---
This patch depends on the following patch:
patchwork.ozlabs.org/patch/176058/
common/lcd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
common/lcd.c +1 -1
@@ -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);
Signature · 1 line
1.7.5.4
PATCH 1/1 common/lcd: add protection from null bmp pointer
Hello Nikita,
Quoted 3 lines · Nikita Kiryanov
If the bmp pointer is null (for example because the environment variable "splashimage" was not defined) then U-Boot will get stuck when trying to load the image.
Which branch is this? At [1] there is a check for this..
1600 s = getenv("splashimage");
1601 if (s != NULL) {
...
Regards,
Jeroen
PATCH 1/1 common/lcd: add protection from null bmp pointer
Hi,
Quoted 6 lines · Nikita Kiryanov
Quoted 3 lines
If the bmp pointer is null (for example because the environment variable "splashimage" was not defined) then U-Boot will get stuck when trying to load the image.
Which branch is this? At [1] there is a check for this..
Quoted 8 lines
1600 s =
getenv("splashimage");
1601 if (s != NULL) {
...Regards,
Jeroen[1] ....
drivers/video/cfb_console.c.....
Just ignore above, since there are apparently more BMP drawing routines, and I mentioned the wrong one. The same check is in lcd.c though:
822: if (do_splash && (s = getenv("splashimage")) != NULL) {
Regards,
Jeroen
PATCH 1/1 common/lcd: add protection from null bmp pointer
Quoted 11 lines · Jeroen Hofstee
Hi,
Quoted 10 lines · Nikita Kiryanov
Quoted 3 lines
If the bmp pointer is null (for example because the environment variable "splashimage" was not defined) then U-Boot will get stuck when trying to load the image.
Which branch is this? At [1] there is a check for this..
1600 s =
getenv("splashimage");
1601 if (s != NULL) {
...
Quoted 9 lines
Quoted 4 lines
Regards,
Jeroen[1] ....
drivers/video/cfb_console.c.....Just ignore above, since there are apparently more BMP drawing routines, and I mentioned the wrong one. The same check is in
lcd.cthough:822: if (
do_splash&& (s =getenv("splashimage")) != NULL) {
You are right; the null splashimage scenario was apparently a bad choice of example. However, lcd_display_bitmap is not a static function, and it appears
in lcd.h. This means that someone might use it outside of common/lcd.c context,
and for that reason it should be made more fault tolerant.
I'll resubmit the patch without the splashimage example in the commit message.
Quoted 3 lines
Regards,
Jeroen