]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
amdgpu/dc: Avoid dereferencing NULL pointer
authorDrew Davenport <ddavenport@chromium.org>
Fri, 27 Oct 2017 18:34:46 +0000 (12:34 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 Nov 2017 16:58:41 +0000 (12:58 -0400)
crtc is dereferenced from within drm_atomic_get_new_crtc_state, so
check for NULL before initializing new_crtc_state.

Signed-off-by: Drew Davenport <ddavenport@chromium.org>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index b94987bb6af9517e8cb6c9850f6607346d6da61f..84591781fca13580cd2c6c20f0788a36861a6d0f 100644 (file)
@@ -3853,8 +3853,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
        /* update planes when needed */
        for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
                struct drm_crtc *crtc = new_plane_state->crtc;
-               struct drm_crtc_state *new_crtc_state =
-                               drm_atomic_get_new_crtc_state(state, crtc);
+               struct drm_crtc_state *new_crtc_state;
                struct drm_framebuffer *fb = new_plane_state->fb;
                bool pflip_needed;
                struct dm_plane_state *dm_new_plane_state = to_dm_plane_state(new_plane_state);
@@ -3864,7 +3863,11 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
                        continue;
                }
 
-               if (!fb || !crtc || pcrtc != crtc || !new_crtc_state->active)
+               if (!fb || !crtc || pcrtc != crtc)
+                       continue;
+
+               new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+               if (!new_crtc_state->active)
                        continue;
 
                pflip_needed = !state->allow_modeset;