* [U-Boot] [PATCH] common/lcd: add protection from null bmp pointer
@ 2012-08-16 10:43 Nikita Kiryanov
2012-08-17 18:13 ` Jeroen Hofstee
0 siblings, 1 reply; 4+ messages in thread
From: Nikita Kiryanov @ 2012-08-16 10:43 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
---
This patch depends on the following patch:
patchwork.ozlabs.org/patch/176058/
common/lcd.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/common/lcd.c b/common/lcd.c
index 88dfa51..fcc09ac 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -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);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] common/lcd: add protection from null bmp pointer
2012-08-16 10:43 [U-Boot] [PATCH] common/lcd: add protection from null bmp pointer Nikita Kiryanov
@ 2012-08-17 18:13 ` Jeroen Hofstee
2012-08-18 11:09 ` Jeroen Hofstee
0 siblings, 1 reply; 4+ messages in thread
From: Jeroen Hofstee @ 2012-08-17 18:13 UTC (permalink / raw)
To: u-boot
Hello Nikita,
On 08/16/2012 12:43 PM, Nikita Kiryanov wrote:
> 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
[1]
http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/video/cfb_console.c;h=19d061f6cbec31615c3193f59a27895f203e959f;hb=HEAD
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] common/lcd: add protection from null bmp pointer
2012-08-17 18:13 ` Jeroen Hofstee
@ 2012-08-18 11:09 ` Jeroen Hofstee
2012-08-20 6:12 ` Nikita Kiryanov
0 siblings, 1 reply; 4+ messages in thread
From: Jeroen Hofstee @ 2012-08-18 11:09 UTC (permalink / raw)
To: u-boot
Hi,
> On 08/16/2012 12:43 PM, Nikita Kiryanov wrote:
>> 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
>
> [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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] common/lcd: add protection from null bmp pointer
2012-08-18 11:09 ` Jeroen Hofstee
@ 2012-08-20 6:12 ` Nikita Kiryanov
0 siblings, 0 replies; 4+ messages in thread
From: Nikita Kiryanov @ 2012-08-20 6:12 UTC (permalink / raw)
To: u-boot
On 08/18/2012 02:09 PM, Jeroen Hofstee wrote:
> Hi,
>> On 08/16/2012 12:43 PM, Nikita Kiryanov wrote:
>>> 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
>>
>> [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) {
>
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.
> Regards,
> Jeroen
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-08-20 6:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-16 10:43 [U-Boot] [PATCH] common/lcd: add protection from null bmp pointer Nikita Kiryanov
2012-08-17 18:13 ` Jeroen Hofstee
2012-08-18 11:09 ` Jeroen Hofstee
2012-08-20 6:12 ` Nikita Kiryanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox