drm/amd/display: Fix NULL ptr when calculating refresh rate
authorJerry (Fangzhi) Zuo <Jerry.Zuo@amd.com>
Tue, 27 Nov 2018 15:51:12 +0000 (10:51 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 29 Nov 2018 19:42:28 +0000 (14:42 -0500)
Calculate preferred refresh rate only when preferred mode exists.

Signed-off-by: Jerry (Fangzhi) Zuo <Jerry.Zuo@amd.com>
Reviewed-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index ce00e56814ed0acc96c8bcb3eefbd8b36a851ec1..c791003c813327c280d97617b8f7d82a3f091512 100644 (file)
@@ -2848,7 +2848,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
        bool native_mode_found = false;
        bool scale = dm_state ? (dm_state->scaling != RMX_OFF) : false;
        int mode_refresh;
-       int preferred_refresh;
+       int preferred_refresh = 0;
 
        struct dc_sink *sink = NULL;
        if (aconnector == NULL) {
@@ -2902,13 +2902,12 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
                decide_crtc_timing_for_drm_display_mode(
                                &mode, preferred_mode,
                                dm_state ? (dm_state->scaling != RMX_OFF) : false);
+               preferred_refresh = drm_mode_vrefresh(preferred_mode);
        }
 
        if (!dm_state)
                drm_mode_set_crtcinfo(&mode, 0);
 
-       preferred_refresh = drm_mode_vrefresh(preferred_mode);
-
        /*
        * If scaling is enabled and refresh rate didn't change
        * we copy the vic and polarities of the old timings