Skip to contentSkip to conversation

video: fbdev: sm501fb: Add some geometry checks.

PATCH Applied Danila Chernetsov 2 participants 2 messages Mar 19, 2025 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: fbdev: sm501fb: Add some geometry checks.

Added checks for xoffset, yoffset settings. Incorrect settings of these parameters can lead to errors in sm501fb_pan_ functions.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 5fc404e47bdf ("[PATCH] fb: SM501 framebuffer driver")
---
 drivers/video/fbdev/sm501fb.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/video/fbdev/sm501fb.c +7 -0
index 7734377b2d87..ed6f4f43e2d5 100644
@@ -327,6 +327,13 @@ static int sm501fb_check_var(struct fb_var_screeninfo *var,
 	if (var->xres_virtual > 4096 || var->yres_virtual > 2048)
 		return -EINVAL;
 
+	/* geometry sanity checks */
+	if (var->xres + var->xoffset > var->xres_virtual)
+		return -EINVAL;
+
+	if (var->yres + var->yoffset > var->yres_virtual)
+		return -EINVAL;
+
 	/* can cope with 8,16 or 32bpp */
 
 	if (var->bits_per_pixel <= 8)
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 11 lines · Danila Chernetsov

Added checks for xoffset, yoffset settings. Incorrect settings of these parameters can lead to errors in sm501fb_pan_ functions.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 5fc404e47bdf ("[PATCH] fb: SM501 framebuffer driver")
---
  drivers/video/fbdev/sm501fb.c | 7 +++++++
  1 file changed, 7 insertions(+)

applied.

Thanks!
Helge