[igt-dev] [PATCH i-g-t 2/5] lib/igt_fb: Fix 32bit integer overflow in the shadow buffer size calculation

Ville Syrjala ville.syrjala at linux.intel.com
Thu Apr 18 19:40:40 UTC 2019


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

16k*16k*16 == 1<<32, so 32bits isn't enough for the result when
we start to have big framebuffers.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/igt_fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index f36096804fdd..d4929019971c 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1912,7 +1912,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
 		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	shadow->strides[0] = ALIGN(width * (shadow->plane_bpp[0] / 8), 16);
-	shadow->size = ALIGN(shadow->strides[0] * height,
+	shadow->size = ALIGN((uint64_t)shadow->strides[0] * height,
 			     sysconf(_SC_PAGESIZE));
 	ptr = mmap(NULL, shadow->size, PROT_READ | PROT_WRITE,
 		   MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-- 
2.21.0



More information about the igt-dev mailing list