drm/amd/display: fix NULL pointer in dm_commit_surfaces
authorJerry Zuo <Jerry.Zuo@amd.com>
Wed, 24 May 2017 15:01:32 +0000 (11:01 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 22:07:36 +0000 (18:07 -0400)
Check if adding surface is failed to prevent NULL pointer deref.

Signed-off-by: Jerry Zuo <Jerry.Zuo@amd.com>
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_types.c

index 4da5a7154cea540709695e8ca41703726d7934de..810373480ed51f476bf753d846af3a15dd2edae4 100644 (file)
@@ -2411,6 +2411,10 @@ static void amdgpu_dm_commit_surfaces(struct drm_atomic_state *state,
                        if (crtc == pcrtc) {
                                add_surface(dm->dc, crtc, plane,
                                            &dc_surfaces_constructed[planes_count]);
+                               if (dc_surfaces_constructed[planes_count] == NULL) {
+                                       dm_error("%s: Failed to add surface!\n", __func__);
+                                       continue;
+                               }
                                dc_stream_attach = acrtc_attach->stream;
                                planes_count++;
                        }