[U-Boot] [PATCH V2 3/7] lcd: prevent unaligned memory access when displaying splash screen
Nikita Kiryanov
nikita at compulab.co.il
Sun Feb 10 12:14:02 CET 2013
Following the discussion in the "Create an API for safely accessing BMP
header fields" patch series, this patch should be dropped.
On 01/31/2013 09:39 AM, Nikita Kiryanov wrote:
> When the bmp file is loaded to an address specified by the environment
> variable "splashimage", its header members might be unaligned.
> This happens because the bmp header starts with two byte size fields followd by
> mostly 32 bit fields. When the address in splashimage is not equal to aligned
> address plus/minus 2, the 32 bit members will be placed in unaligned addresses
> and the result would be a data abort on targets that cannot handle unaligned
> memory accesses.
>
> Check that the address is safe to use, and fix it if it's not.
>
> Cc: Anatolij Gustschin <agust at denx.de>
> Cc: Albert ARIBAUD <albert.u.boot at aribaud.net>
> Cc: Jeroen Hofstee <jeroen at myspectrum.nl>
> Signed-off-by: Nikita Kiryanov <nikita at compulab.co.il>
> Signed-off-by: Igor Grinberg <grinberg at compulab.co.il>
> ---
> Changes in V2: None. Patch introduced in V2.
>
> common/lcd.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/common/lcd.c b/common/lcd.c
> index 66d4f94..104125d 100644
> --- a/common/lcd.c
> +++ b/common/lcd.c
> @@ -1046,6 +1046,14 @@ static void *lcd_logo(void)
> do_splash = 0;
>
> addr = simple_strtoul (s, NULL, 16);
> + /*
> + * In order for the fields of bmp header to be properly aligned
> + * in memory, splash image addr must be aligned to "aligned
> + * address plus 2". Fix addr if necessary.
> + */
> + if (addr % 4 != 2)
> + addr += (addr % 4) ?: 2;
> +
> #ifdef CONFIG_SPLASH_SCREEN_ALIGN
> s = getenv("splashpos");
> if (s != NULL) {
>
--
Regards,
Nikita.
More information about the U-Boot
mailing list