Skip to content

Commit 408cb2a

Browse files
Nikita Zhandarovichvijay-suman
authored andcommitted
drm/repaper: fix integer overflows in repeat functions
commit 4d098000ac193f359e6b8ca4801dbdbd6a27b41f upstream. 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] Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit c177517ea65c728c55d55aa4abaee08a3b932210) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent ff85509 commit 408cb2a

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
@@ -454,7 +454,7 @@ static void repaper_frame_fixed_repeat(struct repaper_epd *epd, u8 fixed_value,
454454
enum repaper_stage stage)
455455
{
456456
u64 start = local_clock();
457-
u64 end = start + (epd->factored_stage_time * 1000 * 1000);
457+
u64 end = start + ((u64)epd->factored_stage_time * 1000 * 1000);
458458

459459
do {
460460
repaper_frame_fixed(epd, fixed_value, stage);
@@ -465,7 +465,7 @@ static void repaper_frame_data_repeat(struct repaper_epd *epd, const u8 *image,
465465
const u8 *mask, enum repaper_stage stage)
466466
{
467467
u64 start = local_clock();
468-
u64 end = start + (epd->factored_stage_time * 1000 * 1000);
468+
u64 end = start + ((u64)epd->factored_stage_time * 1000 * 1000);
469469

470470
do {
471471
repaper_frame_data(epd, image, mask, stage);

0 commit comments

Comments
 (0)