From: =?UTF-8?q?Yannick=20Fertr=C3=A9?= Date: Fri, 13 Sep 2019 11:47:49 +0200 Subject: [U-Boot] [PATCH v4 01/15] video: bmp: check resolutions of panel/bitmap In-Reply-To: <1568368083-11075-1-git-send-email-yannick.fertre@st.com> References: <1568368083-11075-1-git-send-email-yannick.fertre@st.com> Message-ID: <1568368083-11075-2-git-send-email-yannick.fertre@st.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de If the size of the bitmap is bigger than the size of the panel then errors appear when calculating axis alignment and the copy of bitmap is done outside of framebuffer. Signed-off-by: Yannick Fertr=C3=A9 --- drivers/video/video_bmp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index 193f37d..544bd5f 100644 --- a/drivers/video/video_bmp.c +++ b/drivers/video/video_bmp.c @@ -54,6 +54,13 @@ static void video_display_rle8_bitmap(struct udevice *de= v, height =3D get_unaligned_le32(&bmp->header.height); bmap =3D (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset); =20 + /* check if picture size exceed panel size */ + if (priv->xsize < width) + width =3D priv->xsize; + + if (priv->ysize < height) + height =3D priv->ysize; + x =3D 0; y =3D height - 1; =20 @@ -249,6 +256,13 @@ int video_bmp_display(struct udevice *dev, ulong bmp_i= mage, int x, int y, =20 padded_width =3D (width & 0x3 ? (width & ~0x3) + 4 : width); =20 + /* check if picture size exceed panel size */ + if (pwidth < width) + width =3D pwidth; + + if (priv->ysize < height) + height =3D priv->ysize; + if (align) { video_splash_align_axis(&x, priv->xsize, width); video_splash_align_axis(&y, priv->ysize, height); --=20 2.7.4