Skip to content

Commit 4d09800

Browse files
Nikita ZhandarovichAlexLanzano
authored andcommitted
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: 3589211 ("drm/tinydrm: Add RePaper e-ink driver") Cc: [email protected] Signed-off-by: Nikita Zhandarovich <[email protected]> Signed-off-by: Alex Lanzano <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent ed531fe commit 4d09800

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/tiny/repaper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ static void repaper_frame_fixed_repeat(struct repaper_epd *epd, u8 fixed_value,
456456
enum repaper_stage stage)
457457
{
458458
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);
460460

461461
do {
462462
repaper_frame_fixed(epd, fixed_value, stage);
@@ -467,7 +467,7 @@ static void repaper_frame_data_repeat(struct repaper_epd *epd, const u8 *image,
467467
const u8 *mask, enum repaper_stage stage)
468468
{
469469
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);
471471

472472
do {
473473
repaper_frame_data(epd, image, mask, stage);

0 commit comments

Comments
 (0)