drm/amd/display: avoid divided by zero
authorCharlene Liu <Charlene.Liu@amd.com>
Tue, 22 Oct 2024 22:42:56 +0000 (18:42 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 4 Nov 2024 16:33:40 +0000 (11:33 -0500)
[why]
insert divided by zero protection

Reviewed-by: Alvin Lee <alvin.lee2@amd.com>
Signed-off-by: Charlene Liu <Charlene.Liu@amd.com>
Signed-off-by: Zaeem Mohamed <zaeem.mohamed@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/modules/freesync/freesync.c

index fc42687..f980a84 100644 (file)
@@ -129,6 +129,9 @@ unsigned int mod_freesync_calc_v_total_from_refresh(
        unsigned int v_total;
        unsigned int frame_duration_in_ns;
 
+       if (refresh_in_uhz == 0)
+               return stream->timing.v_total;
+
        frame_duration_in_ns =
                        ((unsigned int)(div64_u64((1000000000ULL * 1000000),
                                        refresh_in_uhz)));