From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Kiryanov Date: Sun, 02 Jun 2013 14:05:44 +0300 Subject: [U-Boot] [PATCH] lcd: align bmp header when uncopmressing image In-Reply-To: <1369999573-15449-1-git-send-email-p.wilczek@samsung.com> References: <1369381565-13946-1-git-send-email-p.wilczek@samsung.com> <1369999573-15449-1-git-send-email-p.wilczek@samsung.com> Message-ID: <51AB2708.9080207@compulab.co.il> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Piotr, On 05/31/2013 02:26 PM, Piotr Wilczek wrote: > -bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp) > +bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp, > + void **alloc_addr) > { > void *dst; > unsigned long len; > @@ -60,7 +65,14 @@ bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp) > puts("Error: malloc in gunzip failed!\n"); > return NULL; > } > - if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) { > + > + bmp = dst; > + > + /* align to 32-bit-aligned-address + 2 */ > + if ((unsigned int)bmp % 0x04 != 0x02) > + bmp = (bmp_image_t *)(((unsigned int)dst + 0x02) & ~0x01); This is wrong. Suppose that bmp % 4 == 3, then (dst + 2) % 4 == 1, and thus ((dst + 2) & ~1) % 4 == 0, which is not an aligned+2 address. > + > + if (gunzip(bmp, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) { > free(dst); > return NULL; > } > @@ -68,8 +80,6 @@ bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp) > puts("Image could be truncated" > " (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n"); > -- Regards, Nikita.