diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-09-19 12:42:35 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-09-19 12:42:35 +0000 |
commit | 6e398834c76e113ff1cdfb4c3be214bce4d6b4a2 (patch) | |
tree | 9758f47de803162bca1c7dc2a6e1b4dfb098478c /sys/dev | |
parent | c99b40dc2ae28a0ce5a3703d9aa207409cf4a240 (diff) |
drm/amd/display: prevent potential division by zero errors
From Hamza Mahfooz
ff536a96687cf976d89bed08d40fcaae6bf50304 in linux-6.1.y/6.1.54
07e388aab042774f284a2ad75a70a194517cdad4 in mainline linux
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/drm/amd/display/modules/freesync/freesync.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/pci/drm/amd/display/modules/freesync/freesync.c b/sys/dev/pci/drm/amd/display/modules/freesync/freesync.c index 668133d1555..de9f7c41019 100644 --- a/sys/dev/pci/drm/amd/display/modules/freesync/freesync.c +++ b/sys/dev/pci/drm/amd/display/modules/freesync/freesync.c @@ -338,7 +338,9 @@ static void apply_below_the_range(struct core_freesync *core_freesync, * - Delta for CEIL: delta_from_mid_point_in_us_1 * - Delta for FLOOR: delta_from_mid_point_in_us_2 */ - if ((last_render_time_in_us / mid_point_frames_ceil) < in_out_vrr->min_duration_in_us) { + if (mid_point_frames_ceil && + (last_render_time_in_us / mid_point_frames_ceil) < + in_out_vrr->min_duration_in_us) { /* Check for out of range. * If using CEIL produces a value that is out of range, * then we are forced to use FLOOR. @@ -385,8 +387,9 @@ static void apply_below_the_range(struct core_freesync *core_freesync, /* Either we've calculated the number of frames to insert, * or we need to insert min duration frames */ - if (last_render_time_in_us / frames_to_insert < - in_out_vrr->min_duration_in_us){ + if (frames_to_insert && + (last_render_time_in_us / frames_to_insert) < + in_out_vrr->min_duration_in_us){ frames_to_insert -= (frames_to_insert > 1) ? 1 : 0; } |