If the coordinates are 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é <yannick.fer...@st.com>
---
 drivers/video/video_bmp.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
index 4af1fb4..74267f7 100644
--- a/drivers/video/video_bmp.c
+++ b/drivers/video/video_bmp.c
@@ -256,6 +256,19 @@ int video_bmp_display(struct udevice *dev, ulong 
bmp_image, int x, int y,
                return -EINVAL;
        }
 
+       /* check if coordinates exceeds panel size */
+       if (pwidth < x && x != BMP_ALIGN_CENTER) {
+               printf("Error: Coordinate x %d is bigger than panel width %d\n",
+                      (int)x, (int)pwidth);
+               return -EINVAL;
+       }
+
+       if (priv->ysize < y && y != BMP_ALIGN_CENTER) {
+               printf("Error: Coordinate y %d is bigger than panel height %d\n"
+                      , (int)y, (int)priv->ysize);
+               return -EINVAL;
+       }
+
        if (align) {
                video_splash_align_axis(&x, priv->xsize, width);
                video_splash_align_axis(&y, priv->ysize, height);
-- 
2.7.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to