Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/repaper: fix integer overflows in repeat functions

There are conditions, albeit somewhat unlikely, under which right hand
expressions, calculating the end of time period in functions like
repaper_frame_fixed_repeat(), may overflow.

For instance, if 'factor10x' in repaper_get_temperature() is high
enough (170), as is 'epd->stage_time' in repaper_probe(), then the
resulting value of 'end' will not fit in unsigned int expression.

Mitigate this by casting 'epd->factored_stage_time' to wider type before
any multiplication is done.

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

Fixes: 3589211e9b03 ("drm/tinydrm: Add RePaper e-ink driver")
Cc: stable@vger.kernel.org
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Signed-off-by: Alex Lanzano <lanzano.alex@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250116134801.22067-1-n.zhandarovich@fintech.ru

authored by

Nikita Zhandarovich and committed by
Alex Lanzano
4d098000 ed531fed

+2 -2
+2 -2
drivers/gpu/drm/tiny/repaper.c
··· 456 456 enum repaper_stage stage) 457 457 { 458 458 u64 start = local_clock(); 459 - u64 end = start + (epd->factored_stage_time * 1000 * 1000); 459 + u64 end = start + ((u64)epd->factored_stage_time * 1000 * 1000); 460 460 461 461 do { 462 462 repaper_frame_fixed(epd, fixed_value, stage); ··· 467 467 const u8 *mask, enum repaper_stage stage) 468 468 { 469 469 u64 start = local_clock(); 470 - u64 end = start + (epd->factored_stage_time * 1000 * 1000); 470 + u64 end = start + ((u64)epd->factored_stage_time * 1000 * 1000); 471 471 472 472 do { 473 473 repaper_frame_data(epd, image, mask, stage);